Make WordPress Core

Opened 5 years ago

Last modified 5 years 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)

#1 @shaunbent
5 years 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.

#2 @lewismcarey
5 years ago

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

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


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.

#3 @markoheijnen
5 years 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

#4 @markoheijnen
5 years ago

#22983 was marked as a duplicate.

#5 @markoheijnen
5 years 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.

5 years ago

using array_merge() inside wp_save_image()

#6 @markoheijnen
5 years ago

  • Keywords has-patch added; needs-patch removed

#7 @markoheijnen
5 years ago

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

#8 @SergeyBiryukov
5 years ago

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