#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: |
Description
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
<?php if ( abs( $image_ratio - $image_ratio_compare ) < 0.002 ) {
Should be increased (for example):
<?php 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.
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?
Thanks,
Joe