• Hello,
    I had a problem that I solved my way (read here). But it wasn’t the good solution.
    To me, at least, I found that in fact I had problem with sizes in general as I also got “Unknown image size” error with some “resized” images asked that were in fact of a template size BIGGER than the original.

    So I finally modified fuction filter_wp_get_attachment_metadata in /wp-performance-pack/trunk/modules/dynamic_images/class.wppp_dynamic_images.php as follow:

    function filter_wp_get_attachment_metadata( $data ) {
    	if ( !isset( $data[ 'file' ] ) )
    		return $data;
    	$ext  = strtolower( pathinfo( $data[ 'file' ], PATHINFO_EXTENSION ) );
    	if ( ( $ext === 'jpg' ) || ( $ext === 'jpeg' ) || ( $ext === 'gif' ) || ( $ext === 'png' ) ) { // MR - Added "jpeg" extension as it is found in all regexp inside plugin
    		$name = wp_basename( $data[ 'file' ], ".$ext" );
    
    		$sizes = get_option( 'wppp_dynimg_sizes' );
    		foreach ( $sizes as $size => $sizeinfo ) {
    			if ( !isset( $data[ 'sizes' ][ $size ] ) ) {
    				// MR - Following check should be done inside image_resize_dimensions, but it is not. Don't know why...
    				// Maybe because of the early applied filter 'image_resize_dimensions' inside the core function? No arm done double-checking!
    				if ( ($sizeinfo[ 'width' ] > $data[ 'width' ]) || ($sizeinfo[ 'height' ] > $data[ 'width' ]) ) continue;
    				if ( isset( $sizeinfo[ 'crop' ] ) )
    					$newsize = image_resize_dimensions( $data[ 'width' ], $data[ 'height' ], $sizeinfo['width'], $sizeinfo['height'], $sizeinfo['crop'] );
    				else
    					$newsize = image_resize_dimensions( $data[ 'width' ], $data[ 'height' ], $sizeinfo['width'], $sizeinfo['height'], false );
    				if ( $newsize !== false ) {
    					$data[ 'sizes' ][ $size ] = array (
    						'width' => $newsize[ 4 ],
    						'height' => $newsize[ 5 ],
    						'file' => $name . '-' . $newsize[ 4 ] . 'x' . $newsize[ 5 ] . '.' . $ext,
    					);
    				}
    			}
    		}
    	}
    	return $data;
    }

    Maybe my problem is related to some other plugin (as always suspected). But now, as I’ve checked image_resize_dimensions returns (and read its code too), I now this was my problem and I’ve solved it without really “changing” the plugin’s behavior for other users.

    Hope it helps

    The page I need help with: [log in to see the link]

  • The topic ‘Problem with sizes’ is closed to new replies.