[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 04:01:22 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:
--------------------------------------+------------------------
Changes (by joemcgill):

 * keywords:  needs-patch => has-patch has-unit-tests


Comment:

 [https://core.trac.wordpress.org/attachment/ticket/34955/34955.diff
 34955.diff] uses `wp_constrain_dimensions()` to calculate the expected
 dimensions of the larger size being compared if it were resized to the
 width of the smaller image. By comparing the expected dimensions to the
 actual dimensions of the smaller image, we should be able to reliably tell
 if the current image size has the same aspect ratio and, if so, include it
 in the `srcset` attribute.

 I've added a test using the example from this ticket to show the failing
 behavior, which is fixed by this patch.

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


More information about the wp-trac mailing list