Overwriting a core Wordpress function - should work but it doesn't
Posted
by Will Ashworth
on Stack Overflow
See other posts from Stack Overflow
or by Will Ashworth
Published on 2010-04-16T18:55:12Z
Indexed on
2010/04/17
1:53 UTC
Read the original article
Hit count: 271
I'm trying to overwrite a core Wordpress function (found in media.php) using add_filter() in my theme's functions.php file. This should work accord to the blogs that I've come across, but for some reason I see no change whatsoever.
#override what WP is trying to do to scaling images by default
function my_image_hwstring($width, $height) {
$out = '';
#if ($width)
# $out .= 'width="'.intval($width).'" ';
#if ($height)
# $out .= 'height="'.intval($height).'" ';
return $out;
}
add_filter('image_hwstring', 'my_image_hwstring', 1, 2);
I prefer to not edit media.php manually because any Wordpress upgrades later will overwrite the changes we've made. The way I'm doing it is correct (I think) but isn't working as expected.
Totally hung up on this and appreciate any responses. This is a weird one!
© Stack Overflow or respective owner