Overwriting a core Wordpress function - should work but it doesn't
- by Will Ashworth
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!