VERY Useful but need a little upgrade
-
The problem wouldn’t arise if you’re assigning medium to large images. In my case, I used small-sized icons 50×50 pixels as a category thumbnail, and WordPress threw a notice “Notice: image_resize is deprecated since version 3.5! Use wp_get_image_editor() instead.” in wp-admin/edit-tags.php?taxonomy=category page
I solved the notice by using the recommended wp_get_image_editor() API as follows. Comment-out the image_resize() API, and add two lines of $new = wp_get_image_editor(…….);
$new->resize( $detail[‘size’][0], $detail[‘size’][1], $detail[‘size’][2] );Location: taxonomy-images.php line 176
/* Attempt to create a new downsized version of the original image. $new = image_resize( $path, $detail['size'][0], $detail['size'][1], $detail['size'][2] );*/ $new = wp_get_image_editor( $path ); // Return an implementation that extends <tt>WP_Image_Editor</tt> /* Image creation successful. Generate and cache image metadata. Return url. */ if ( ! is_wp_error( $new ) ) { $new->resize( $detail['size'][0], $detail['size'][1], $detail['size'][2] ); $meta = wp_generate_attachment_metadata( $id, $path ); wp_update_attachment_metadata( $id, $meta ); $img = image_get_intermediate_size( $id, $detail['name'] ); if ( isset( $img['url'] ) ) { return $img['url']; } }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘VERY Useful but need a little upgrade’ is closed to new replies.