WordPress.org

Make WordPress Core

#21457 closed defect (bug) (duplicate)

Applying changes in image editor loses meta data for any additional image sizes

Reported by: prettyboymp Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description

When using the image editor, the wp_save_image function only generates images for the core image sizes and ignores any of the theme registered images sizes. This causes the full sized image to be used everywhere that the custom image size is called in the theme.

Attachments (1)

21457.diff (1.2 KB) - added by prettyboymp 21 months ago.

Download all attachments as: .zip

Change History (3)

prettyboymp21 months ago

comment:1 prettyboymp21 months ago

Reproduction steps:

  1. add add_image_size('test-300x300', 300, 300, true); to functions.php in theme
  2. upload an new image through the media library
  3. check the meta values for the uploaded image
//current meta for media
   meta_id: 3508
   post_id: 42756
  meta_key: _wp_attachment_metadata
meta_value: a:6:{s:5:"width";i:3072;s:6:"height";i:2304;s:14:"hwstring_small";s:23:"height='96' width='128'";s:4:"file";s:20:"2012/08/IMG_0969.jpg";s:5:"sizes";a:5:{s:9:"thumbnail";a:3:{s:4:"file";s:20:"IMG_0969-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;}s:6:"medium";a:3:{s:4:"file";s:20:"IMG_0969-300x225.jpg";s:5:"width";i:300;s:6:"height";i:225;}s:5:"large";a:3:{s:4:"file";s:21:"IMG_0969-1024x768.jpg";s:5:"width";i:1024;s:6:"height";i:768;}s:12:"test-300x300";a:3:{s:4:"file";s:20:"IMG_0969-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;}s:14:"post-thumbnail";a:3:{s:4:"file";s:20:"IMG_0969-624x468.jpg";s:5:"width";i:624;s:6:"height";i:468;}}s:10:"image_meta";a:10:{s:8:"aperture";d:2.7999999999999998;s:6:"credit";s:0:"";s:6:"camera";s:21:"Canon PowerShot SD750";s:7:"caption";s:0:"";s:17:"created_timestamp";i:1333862434;s:9:"copyright";s:0:"";s:12:"focal_length";d:5.7999999999999998;s:3:"iso";s:3:"200";s:13:"shutter_speed";d:0.016666666666666666;s:5:"title";s:0:"";}}
  1. click edit image and apply a crop
  2. check the meta values for the image, note that the meta for the 'test-300x300' image is missing for the current '_wp_attachment_metadata' metakey
//new meta values for the image:
   meta_id: 3508
   post_id: 42756
  meta_key: _wp_attachment_metadata
meta_value: a:6:{s:5:"width";i:952;s:6:"height";i:960;s:14:"hwstring_small";s:22:"height='96' width='95'";s:4:"file";s:35:"2012/08/IMG_0969-e1344353338375.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:3:{s:4:"file";s:35:"IMG_0969-e1344353338375-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;}s:6:"medium";a:3:{s:4:"file";s:35:"IMG_0969-e1344353338375-297x300.jpg";s:5:"width";i:297;s:6:"height";i:300;}}s:10:"image_meta";a:10:{s:8:"aperture";d:2.7999999999999998;s:6:"credit";s:0:"";s:6:"camera";s:21:"Canon PowerShot SD750";s:7:"caption";s:0:"";s:17:"created_timestamp";i:1333862434;s:9:"copyright";s:0:"";s:12:"focal_length";d:5.7999999999999998;s:3:"iso";s:3:"200";s:13:"shutter_speed";d:0.016666666666666666;s:5:"title";s:0:"";}}
*************************** 3. row ***************************
   meta_id: 3509
   post_id: 42756
  meta_key: _wp_attachment_backup_sizes
meta_value: a:6:{s:9:"full-orig";a:3:{s:5:"width";i:3072;s:6:"height";i:2304;s:4:"file";s:12:"IMG_0969.jpg";}s:14:"thumbnail-orig";a:3:{s:4:"file";s:20:"IMG_0969-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;}s:11:"medium-orig";a:3:{s:4:"file";s:20:"IMG_0969-300x225.jpg";s:5:"width";i:300;s:6:"height";i:225;}s:10:"large-orig";a:3:{s:4:"file";s:21:"IMG_0969-1024x768.jpg";s:5:"width";i:1024;s:6:"height";i:768;}s:17:"test-300x300-orig";a:3:{s:4:"file";s:20:"IMG_0969-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;}s:19:"post-thumbnail-orig";a:3:{s:4:"file";s:20:"IMG_0969-624x468.jpg";s:5:"width";i:624;s:6:"height";i:468;}}

At this point the full size image gets pulled in anywhere that thumbnail size is used.

comment:2 SergeyBiryukov21 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Introduced in [18996].

#19889 also has a patch, going to close as a duplicate of that ticket.

Note: See TracTickets for help on using tickets.