Forum Replies Created

Viewing 1 replies (of 1 total)
  • Selecting “Full Size” passes in the dimensions of the full size image to image_resize_dimensions(), which returns false since we don’t need to resize the image. When image_resize_dimensions() returns false, image_resize() returns an error object.
    http://core.trac.wordpress.org/ticket/12268

    So the following if statement does not do what it should:
    if ($image = image_resize( $imgpath, $width, $height ))

    To make it work, we test if the original dimensions are the same as the destination dimensions before passing them in to image_resize().

    Change lines 76-80 of image-widget.php from:

    if ($image = image_resize( $imgpath, $width, $height )) {
    	$image = path_join( dirname($attachment_url), basename($image) );
    } else {
    	$image = $attachment_url;
    }

    To:

    //Get original image size
    $size = @getimagesize( $imgpath );
    list($orig_w, $orig_h, $orig_type) = $size;
    $image = image_resize( $imgpath, $width, $height );
    
    if ( ($orig_w == $width && $orig_h == $height) || !$image) {
    	$image = $attachment_url; //No resizing necessary.
    } else {
    	$image = path_join( dirname($attachment_url), basename($image) );
    }

    You will need to hit “Save” on each active widget to make the image appear.

Viewing 1 replies (of 1 total)