[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
Fri Dec 11 04:17:45 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 smerriman):
What if you do use a pixel difference, but always in reference to
shrinking the larger size to the smaller size, whichever way around it is?
That is, if your current image is axb and you want to see if cxd should be
added to the srcset:
If c>a and the srcset image was used, the axb image would be replaced by
ax(d*a/c), so check if |b-d*a/c|<=1.
If c<a, the only time the srcset image will be used if it has been shrunk
with CSS to at most c wide already. So it's actually being display at
cx(b*c/a) initially and being replaced by cxd, so check if |d-b*c/a|<=1.
I think this solves the original issue of 480x188 and 4000x1563 - because
rather than comparing 4000x1537 with 4000x1567.66 which fails, you'd be
comparing 480x188 and 480x187.56, which succeeds.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34955#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list