public function trim( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ){
        $editor = wp_get_image_editor( $file );
        if ( is_wp_error( $editor ) )
            return $editor;
        $editor->set_quality( $jpeg_quality );

        $resized = $editor->resize( $max_w, $max_h, $crop );
        if ( is_wp_error( $resized ) )
            return $resized;

        $dest_file = $editor->generate_filename( $suffix, $dest_path );
        $saved = $editor->save( $dest_file );

        if ( is_wp_error( $saved ) )
            return $saved;

        return $dest_file;
    }
public function trim( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 90 ){
        $editor = wp_get_image_editor( $file );
        if ( is_wp_error( $editor ) )
            return $editor;
        $editor->set_quality( $jpeg_quality );

        $resized = $editor->resize( $max_w, $max_h, $crop );
        if ( is_wp_error( $resized ) )
            return $resized;

        $dest_file = $editor->generate_filename( $suffix, $dest_path );
        $saved = $editor->save( $dest_file );

        if ( is_wp_error( $saved ) )
            return $saved;

        return $dest_file;
    }
public function trim ( $ file , $ max_w , $ max_h , $ crop = false , $ suffix = null , $ dest_path = null , $ jpeg_quality = 90 ) { $ editor = wp_get_image_editor ( $ file ) ; if ( is_wp_error ( $ editor ) ) return $ editor ; $ editor -> set_quality ( $ jpeg_quality ) ; $ resized = $ editor -> resize ( $ max_w , $ max_h , $ crop ) ; if ( is_wp_error ( $ resized ) ) return $ resized ; $ dest_file = $ editor -> generate_filename ( $ suffix , $ dest_path ) ; $ saved = $ editor -> save ( $ dest_file ) ; if ( is_wp_error ( $ saved ) ) return $ saved ; return $ dest_file ; }
Clone of image resize

@see image_resize
@param string $file Image file path.
@param int $max_w Maximum width to resize to.
@param int $max_h Maximum height to resize to.
@param bool $crop Optional. Whether to crop image or resize.
@param string $suffix Optional. File suffix.
@param string $dest_path Optional. New image file path.
@param int $jpeg_quality Optional, default is 90. Image quality percentage.
@return mixed WP_Error on failure. String with new destination path.
Clone of image resize