• Hi,

    Working with WordPress 3.0RC1, I’m finding that if I choose Full Size when adding an image via the Image Widget (either upload or from library), after Save, the image is missing both in the widget admin and on the site. Checking the source, I see that the image URL contains the path but not the actual image.

    Choosing Thumbnail, Medium or Large, it’s fine. Only with Full Size that it breaks.

    I don’t know if this is a 3.0RC1 issue, or an Image Widget issue, exposed by 3.0RC1?

    Any ideas?

    Thanks,
    Chris

    http://wordpress.org/extend/plugins/image-widget/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m having the same issue. 3.0-RC2

    Haven’t found a fix yet.

    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.

    If I told you you made my Saturday, would you believe me? Well, the “Plan B” temp fix first mentioned worked – and I was grateful for that. But your permanent fix did, as well. And that would be that. Seriously, my sincerest thanks.

    I’ve updated the plugin in 3.1.6 to fix wordpress 3.0 bugs. let me know if this solves it.

    Thanks!

    ~p

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Image Widget] Image url breaks if size = Full Size (WordPress 3.0 RC1)’ is closed to new replies.