WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Image Widget] Image url breaks if size = Full Size (WordPress 3.0 RC1) (5 posts)

  1. chriscollier
    Member
    Posted 4 years ago #

    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/

  2. Patrick Daly
    Member
    Posted 4 years ago #

    I'm having the same issue. 3.0-RC2

    Haven't found a fix yet.

  3. ithackston
    Member
    Posted 4 years ago #

    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.

  4. chandlerwhite
    Member
    Posted 4 years ago #

    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.

  5. Peter Chester
    Modern Tribe
    Posted 4 years ago #

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

    Thanks!

    ~p

Topic Closed

This topic has been closed to new replies.

About this Topic