Wordpress 3.5 is here and those who are using the great Victor Teixeira image resize script some warnings might have appeared on your WordPress installation. The image_resize function is still working, but deprecated (in favor of the “wp_get_image_editor” function). This means that it should stop working someday.
I took a look into the code and found a way to replace the old function. The first thing to do is search for the “image_resize” string and comment that line of code (just like shown on the first line of the code below). Then insert the following lines of code:
$editor = wp_get_image_editor( $file_path );
if ( is_wp_error( $editor ) )
return $editor;
$editor->set_quality( 100 );
$resized = $editor->resize( $width, $height, $crop );
$dest_file = $editor->generate_filename( NULL, NULL );
$saved = $editor->save( $dest_file );
if ( is_wp_error( $saved ) )
return $saved;
$new_img_path=$dest_file;
This will keep this script working perfectly for the next 30 years! Well, maybe not that long…
Edit: in the meantime I have made some changes and adjustments to the script. One of the things that I did was adding the retina images option. If true this option will serve images and scale them to 50% of their size so that they look good on retina devices.
You can find the latest version of the script here: https://gist.github.com/Pirenko/6734d0689b3629cd370f
Hi, just saw your post… Glad you updated my old function… Thanks
Super cool.. I was just reading through this function and here is the guy who wrote it. Thanks, Victor
Thanks for updating the function. This is what I was looking for.
It is now the year 2014 bordering on 2015, and I\’ve found that vt_resize works perfectly for me, are there any known issues with using it at this time?
Hi,
I\’m still using it on all of my themes. I\’ve made some edits in the meantime and I have added just a link to a Gist if you are interested. You will find this link on the bottom of the article just above.
Thanks!