• 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

    (@rvencu)

    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.