Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#12218 closed defect (bug) (fixed)

image_get_intermediate_size() may return croped image when full image is requested

Reported by: dd32 Owned by: markjaquith
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords:
Focuses: Cc:


At present image_get_intermediate_size() is not aware of croped images, infact, Images being croped is not stored in the meta data at all.

This has caused a bug to appear in the twentyten theme which uses a post thumbnail of 940x198px (croped).

If you upload an image 1024x768, and attempt to display it as 640x480, you'll recieve the next largest image which fits, image_get_intermediate_size() will return the 940x198px version. (For example, On the twentyten Attachment page)

The solution i've come accross is to store if the image has been auto-croped in the meta data, and upon retrieval, only return croped images for sizes which speecify croped as OK.

I'm attaching a POC patch, ideally, it should automatically add the list of custom image sizes which are cropped and test against that.

Attachments (2)

only_croped_images_for_thumbnails.diff (1.3 KB) - added by dd32 10 years ago.
do_not_use_crops_for_image_get_intermediate_size.diff (1.2 KB) - added by markjaquith 10 years ago.

Download all attachments as: .zip

Change History (5)

#1 @markjaquith
10 years ago

  • Component changed from Upload to Media
  • Owner set to markjaquith
  • Status changed from new to accepted

My attachment skips past crops (except for the thumbnail size, which it will always consider), and determines whether an image is a crop by calculations against the full image size (which means it requires no new data storage, and will work with previously uploaded images).

#2 @markjaquith
10 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [13145]) Skip intermediate sizes of a different aspect ratio than the original image when considering which image to use in image_get_intermediate_size(). fixes #12218

Note: See TracTickets for help on using tickets.