WordPress.org

Make WordPress Core

Opened 16 months ago

Last modified 10 months ago

#22985 closed defect (bug)

Edit thumbnail image only - loses all sub sizes in attachment meta — at Version 8

Reported by: lewismcarey Owned by: markoheijnen
Milestone: 3.5.1 Priority: high
Severity: critical Version: 3.5
Component: Media Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I have several additional image sizes in my theme. When I crop an image and save over only the thumbnail, all references to the various sub-sizes are lost and only the new thumbnail is referenced in _wp_attachment_metadata.

  1. Add an image to the media library.
  2. Output _wp_attachment_metadata.
  3. Edit the image (crop).
  4. Save only the thumbnail.
  5. Output the relevant _wp_attachment_metadata.

This may be an issue with wp_save_image() not re-genarating subsizes from the original.
I believe this to be different from Ticket #19889 as it appears to remove references to default sizes from media settings screen.

Change History (9)

comment:1 shaunbent16 months ago

Whilst testing for this issue I have noticed that when using the 'Apply to all image sizes' option that custom image sizes are excluded here as well - so this issue doesn't seem to be limited to just the thumbnail only option.

comment:2 lewismcarey16 months ago

The main diff I can see between image-edit.php 3.4 & 3.5 is

695     $meta['sizes'] = $img->multi_resize( $_sizes );

replaces

596    if ( $resized )
597        $meta['sizes'][$size] = $resized;
598    else
599        unset($meta['sizes'][$size]);

before wp_update_attachment_metadata($post_id, $meta); is called on success.

comment:3 markoheijnen16 months ago

  • Milestone changed from Awaiting Review to 3.5.1
  • Owner set to markoheijnen
  • Status changed from new to assigned

I will look into this today. I can see the issue with the code lewis send but I need to look into the context of that since for what I think that get called when a new image getting uploaded. So if that is true that code is unrelated

comment:4 markoheijnen16 months ago

#22983 was marked as a duplicate.

comment:5 markoheijnen16 months ago

  • Keywords needs-patch added

Testing it and yes the multi_resize() call in wp_save_image() is wrong. It will then only put the changed images as meta sizes.

markoheijnen16 months ago

using array_merge() inside wp_save_image()

comment:6 markoheijnen16 months ago

  • Keywords has-patch added; needs-patch removed

comment:7 markoheijnen16 months ago

  • Priority changed from normal to high
  • Severity changed from major to critical

comment:8 SergeyBiryukov16 months ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.