Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#35193 closed defect (bug) (duplicate)

$image_ratio_compare variance increase

Reported by: greenzilla Owned by:
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Media Keywords:
Focuses: Cc:


I'm calling this a bug since I believe it is not the desired natural functionality for my case which I imagine could be the similar case for others.

Line 1065 in wp-includes\media.php
if ( abs( $image_ratio - $image_ratio_compare ) < 0.002 ) {

Should be increased (for example):

if ( abs( $image_ratio - $image_ratio_compare ) < 0.01 ) {

For testing purposes, my media settings have custom image sizes created for 50, 100, 150, 200, 250, 300, 400, 500, 600, 700, 800, 900 and 1,000. (some of these sizes are set as the default image sizes).

I am not cropping any of the images (so not changing the aspect ratio). However, this variance is not allowing for certain sizes to be returned in the $srcset. It is my understanding that this variance is to ensure cropped images are not returned. However, I am not being returned all the images that are within the native ratio.

I believe there should at least be a filter to adjust this variance.

I used 0.01 in my tests to return all the images with the native ratio. My tests showed the highest deviation was 0.00941.

I have tested this with vertical, horizontal and square images.

Do note that in my environment, I am using 'WP_Image_Editor_Imagick' as the image editor via the 'wp_image_editors' filter.

Change History (4)

#1 @joemcgill
5 years ago

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

Hi @greenzilla,

I believe this is a duplicate of #34955. Can you test the patch in that ticket and see if it fixes your issue as well?


#2 @greenzilla
5 years ago

@joemcgill Apologies for the duplicate. The patch in #34955 indeed resolved my issue. I'll be using this in production. Will note if I come across any issues there.

#3 @joemcgill
5 years ago

No problem. Thanks @greenzilla.

#4 @rachelbaker
5 years ago

  • Milestone set to 4.5

Duplicate of #34955.

Note: See TracTickets for help on using tickets.