[wp-hackers] Replacing image_resize() function?
raul.peixoto at gmail.com
Wed Apr 8 16:40:26 GMT 2009
I'm new to this list, so it will be the first time writing to this list, so I hope to enjoy my time here!
I'm working on a way to replace the image_resize() function, inside wp-includes/media.php and I need some advice regarding this...
Wordpress allows me to crop, or even generate new image sizes (with a proper hook into the additional_image_sizes function), however I'm working on a project that requires me to rewrite the image_resize function...
Why is that?
Well, I need to resize all images to an exact specific size (let's say 120x90 for thumbnail size, and 250x125 for medium size) but I need to do this without cropping. So the only way is to resize and then add a margin to comply with the desired size.
I have created the new function and named it sp_image_resize.
Hacking the core files:
Now the way I got this to work was by hacking into /wp-includes/media.php, inside function: image_make_intermediate_size, around line 412
change: $resized_file = image_resize($file, $width, $height, $crop);
to: $resized_file = sp_image_resize($file, $width, $height, $crop);
So are there any ideas to replace this function without hacking the core directly?
I tried to add_filter( 'image_resize', 'sp_image_resize', 1, 4 ); but it doesn't work.
I also tried to replace the image_make_intermediate_size the same way but with no success.
Can someone help?
Thanks in advance,
More information about the wp-hackers