Why can’t I edit certain images from the WordPress Media library?

I’ve noticed some bizarre behaviour in my WordPress installation.

For some photos, when I click “Edit Image”, the full image is not displayed to me – just the area visible in the thumbnail. And yet, if you click “View Image”, you can see the full image is actually there.

Read More

Clearly needs some fixing

Clearly, some manual intervention is required for this pic’s thumbnail.

Edit Image shows same weird crop

Click on edit image, only to find the whole image is not presented to me for cropping/editing. Has the image been cropped on upload, maybe?

The whole image is there

View attachment shows that no, the whole image is actually there – its just not available to me in the image editor.

What’s going on?

This is only an issue for certain photos, and I can’t see any difference between them – they are all JPGs, and there is no weird EXIF data that I can see… and yet some photos I can crop, and others not…

Related posts

Leave a Reply

4 comments

  1. what you are describing here (cropped big size image in Edit Media screen) is a perfectly normal behavior when you use Apply changes to: All image sizes while cropping image and I believe the same thing could happen during upload when $crop param is set to true for all registered image sizes (similar to how add_image_size function works) As suggested above – deactivate image-related plugins and see what happens.

    Anyway – the strangest thing is that there’s no Restore Original Image button in your screenshot. This button is exactly what you need to work with the original size in editor.

    See the update below…

    I can replicate this only AFTER I crop the image but BEFORE i save it. The Restore Original Image button appears there as soon as I come back to edit it again after saving it.

    See my screenshot:
    After saving it and coming back

    This is apparently not a final answer, but it doesn’t really fit the comment format so it ended up here…

    UPDATE:
    From looking at the source of image-edit.php it seems that a crucial role in decision whether to display the ‘Restore..’ link is a value of _wp_attachment_backup_sizes post meta field of a given attachment.

    I would suggest checking that value for the problematic attachments. You can use something like this:

    <pre>
    <?php print_r( get_post_meta( $your_attachment_id_here, '_wp_attachment_backup_sizes', true ) ); ?>
    </pre>
    

    (or use the WordPress Console plugin)

    Maybe you will find something odd there. Try also comparing these values between the broken and correctly displayed attachments… Again I know I’m not giving you the answer you’d like to hear but I believe this could be the right direction to investigate.
    Cheers

  2. The same thing is happening to me. I found this page describing the same problem. It seems that it could be caused by the theme. Though changing the theme does not resolve the issue for me (and I have all my plugins disabled too).

    I think this only happens on my images which are taller than they are wide (“portrait” orientation). If the image is wider than it is tall, it gets resized to fit correctly. Gotta be some bug in WordPress’s image resizing algorithm. grrr…

    Annoying workaround: edit image and change the image size, adding “padding” to the sides so that the are wider than tall (if you’re in Photoshop, change the canvas size, alt-ctrl-c). Then re-upload the image to wordpress.

    Running WordPress 3.2.1/ PHP 5.2.17 / twentyeleven theme / no plugins

    Tried running the auto “Re-Install WordPress” (clicked button on the Update tab), but it didn’t change anything.


    Could be something to do with the image size (tested with jpeg images):

    • Worked ok on a 500px x 1000px image
    • Failed on a 400px x 600px image
    • OK on a 500 x 600px image
    • Failed on a 400 x 800px image
    • OK on a 410 x 500px image
    • OK on a 401 x 500px image
    • Failed on a 400 x 500px image
    • OK on a 399 x 500px image
    • Failed on a 400 x 380px image

    Seems to only fail when the image is exactly 400px wide


    I filed a bug report for this. Hopefully the WordPress devs can look at this.

  3. I’ve created this simple function to get it.

    function get_attachment_full_original($id){
        $img = pathinfo( get_attached_file($id) );
        $meta = get_post_meta($id, '_wp_attachment_backup_sizes', true);
        $orig = $meta['full-orig'];
        return str_replace(ABSPATH, get_bloginfo('url') . "/", path_join($img['dirname'], $orig['file']));
    }
    
  4. Look in your theme files for:

    add_image_size( 'thumb_name', some_number, 400, true );
    

    Where thumb_name and some_number could be anything. Simply remove , true:

    add_image_size( 'thumb_name', some_number, 400 );
    

    Or if you need hard crop mode, change 400 to any other number (399 or 401 is fine)

    add_image_size( 'thumb_name', some_number, 401, true );
    

    I spent many hours researching this issue, and it’s definitely a bug (even in WordPress 3.4.1). As kristi mentions, it occurs with images that are 400 pixels wide. It also occurs if your theme adds an image size with a height of 400 pixels and hard crop mode enabled. I’ve updated the bug report, and I hope it gets fixed soon!