[wp-trac] [WordPress Trac] #34955: The choices of images to add to srcset shouldn't be via a ratio

WordPress Trac noreply at wordpress.org
Thu Dec 10 13:37:50 UTC 2015


#34955: The choices of images to add to srcset shouldn't be via a ratio
--------------------------------------+------------------------
 Reporter:  smerriman                 |       Owner:  joemcgill
     Type:  defect (bug)              |      Status:  assigned
 Priority:  normal                    |   Milestone:  4.4.1
Component:  Media                     |     Version:  4.4
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------

Comment (by jaspermdegroot):

 In #34810 I added a link to the PR in the Responsive Images plugin repo
 (where early development of this feature took place) where we switched to
 using aspect ratio. The problem reported by the OP was that a full size
 image was 4px less high than expected based on our calculation so it
 wasn't included in the `srcset` (max allowed difference was 2px at that
 time) while it should have been.
 In #34810 I also linked to an issue reported on the plugin support forum,
 about the accepted aspect ratio difference being too permissive. My
 calculation shows that an image size was 4px less high than expected, but
 in this case it shouldn't have been included in the `srcset`.
 I think this shows that we shouldn't simply switch back to allowing a
 certain amount of pixels difference.

 Using `wp_constrain_dimensions()` might be the solution, but maybe we have
 to use the width and height of the full size image as parameters when it's
 a soft cropped image. When the `src` image is an intermediate size it's
 width or height already has been rounded so if we pass that to the
 function that again does some rounding we might get undesired results.


 Ps. @joemcgill - There is a typo in the inline doc in your patch:
 contstrained --> constrained

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34955#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list