views:

126

answers:

2

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!

A: 

What's the name of the core function you're trying to hook into? These might help: WordPress 2.9 - List of all hooks and filters and PHP Cross Reference (PHPXref) of: WordPress 2.9.1

songdogtech
This one. image_hwstring() inside media.php as part of the core files. According to references I've found online I should be able to overwrite any core function using the example above I am attempting to use.
Will Ashworth
Should be able to. Check codex.wordpress.org/Plugin_Resources
songdogtech
A: 

Just to clear the obvious, you're not running any form of cache system right? Like a cache plugin like wp-cache or wp-super cache? If so, try clearing/flushing the cache.

Jorge Israel Peña
Nope, no caching. Good question though. This is just a plain old vanilla Wordpress installation...with a theme I'm building.
Will Ashworth