[wp-trac] [WordPress Trac] #46885: Improvements/Issues with srcsets, additions to wp_calculate_image_srcset
WordPress Trac
noreply at wordpress.org
Fri Apr 12 18:02:37 UTC 2019
#46885: Improvements/Issues with srcsets, additions to wp_calculate_image_srcset
-------------------------+------------------------------
Reporter: pinktank | Owner: joemcgill
Type: enhancement | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 5.1
Severity: normal | Resolution:
Keywords: | Focuses:
-------------------------+------------------------------
Comment (by pinktank):
If you don't mind helping with the ??? in the code below, I can add it to
the documentation as a comment.
{{{
// Parse through array to unset the original src
foreach($sources as $elementKey => $element) {
foreach($element as $width => $source) {
if($source == ???){
unset($array[$width]);
}
}
}
// Move largest derivative to first position.
$largest_img_key = max(array_keys($sources));
$sources = array( $largest_img_key => $sources[$largest_img_key]) +
$sources;
}}}
On number 3, what I mean is if you have an image that is off by one px in
image ratio due to rounding, this causes the image to jiggle in resizes
and get blurry in conditions where the aspect ratio is determined by the
original width/height. If a developer could disable the 1px error margin
or specify which specific image sizes they want to use, they can choose to
only show images that are resized in multiples of 2, say 180w 360w 720w to
avoid potential 1px shifts in the dom. I suppose this can again be handled
by a loop per above though via white listing, could even be done by
checking the modulo of original src / resized src.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46885#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list