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 ) )
$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 ) )
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
Leave a Comment