WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 6 months ago

#52495 new defect (bug)

Hard cropped images do not crop specified dimension, causing lack of adaptive images

Reported by: larssg Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.6.1
Component: Media Keywords:
Focuses: Cc:

Description

If an image is less than the size of a specified image size, it will be cropped only on the dimension that is greater than the specified dimension. The result is an image that is not the same aspect ratio as other images with specified image sizes that have the same aspect ratio. So it won't output those other images in an srcset and your site may be loading much larger images than needed for mobile.

For example, I might have defined image sizes of 1000x500, 750x375 and 500x250 and use those images in my theme. Normally, I'd insert that largest image and then the other two would be in an srcset. But, if I were to upload and 960x600 image, I'll get a 960x500 image, as well as the normal 750x375 and 500x250. Because these aren't the same aspect ratio, when I insert the larger image, there is no srcset. Now visitors are stuck loading the largest image.

It would make sense to me for hard crop to scale the image up to meet the minimum size for both dimensions, then crop.

Change History (2)

#1 @larssg
6 months ago

Alternately, if scaling up the image isn't desired, it could simply crop the image to the correct aspect ratio, respecting current sizes.

#2 @hellofromTonya
6 months ago

  • Component changed from General to Media
Note: See TracTickets for help on using tickets.