Title: How to replace image_resize function
Last modified: January 7, 2017

---

# How to replace image_resize function

 *  Resolved [Richard Vencu](https://wordpress.org/support/users/rvencu/)
 * (@rvencu)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/how-to-replace-image_resize-function/)
 * I have a theme creating some thumbnails (from already optimized images I guess)
   that end up not optimized. The theme uses image_resize() function.
 * How to apply a filter or replace this function by using Imagify plugin functions?
   I want to ensure these thumbnails are always generated/saved in compressed form.
 * I saw the PHP API class but I wonder if it is not already included in some form
   in the Imagify plugin.

Viewing 1 replies (of 1 total)

 *  Thread Starter [Richard Vencu](https://wordpress.org/support/users/rvencu/)
 * (@rvencu)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/how-to-replace-image_resize-function/#post-8629246)
 * OK, I used this code after I required the php library at the top of the file:
 *     ```
       $new_img_path = image_resize($file_path, $width, $height, $crop); //existing code
       			//richard imagify optimize thumbnails - new code
       			$imagify = new Imagify\Optimizer( 'myapikey' );
       			$handle = $imagify->optimize( $new_img_path, array( "level"=> 'ultra' ) );
       			if ( true === $handle->success ) {
       				$image_data = file_get_contents( $handle->image );
       				file_put_contents( $new_img_path, $image_data );
       				error_log( $new_img_path . ' optimized' );
       			} else {
       				error_log( $handle->message );
       			}
       			//end optimization */
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘How to replace image_resize function’ is closed to new replies.

 * ![](https://ps.w.org/imagify/assets/icon-256x256.gif?rev=3452959)
 * [Imagify: Optimize Images for Top Speed (Compress & Convert to WebP/AVIF)](https://wordpress.org/plugins/imagify/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/imagify/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/imagify/)
 * [Active Topics](https://wordpress.org/support/plugin/imagify/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/imagify/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/imagify/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [Richard Vencu](https://wordpress.org/support/users/rvencu/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/how-to-replace-image_resize-function/#post-8629246)
 * Status: resolved