[wp-trac] [WordPress Trac] #36154: wp_calculate_image_srcset() filters out square resized feature image
WordPress Trac
noreply at wordpress.org
Wed Mar 16 11:01:39 UTC 2016
#36154: wp_calculate_image_srcset() filters out square resized feature image
--------------------------+------------------------
Reporter: solo14000 | Owner: joemcgill
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Media | Version: 4.4.2
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+------------------------
Comment (by jbd7):
Hi @joemcgill,
I am having a similar issue. All my posts have a featured image, which is
sometimes a ratio=1.78 image, sometimes a ratio=1.5. There are various
sizes of thumbnails generated, including square ones for Archives pages,
and I am happy with that.
My theme homepage now uses these images to display a grid of featured
posts. Regardless of the ratio, all images are included the same way:
{{{
<img width="890" height="500" src="http://mydomain.com/wp-
content/uploads/2013/02/featured-image-890x500.jpg" class="attachment-
wide-thumbnail size-wide-thumbnail wp-post-image" alt="...
}}}
The theme is generating this 890x500 size, and all my images have
`-890x500.jpg` versions. 890x500 is a ratio of 1.78, so my ratio=1.5
images are slightly cropped, and I am happy with that.
Because on Desktop, the max width of these images is 220px, I naturally
want `srcset` to offer browsers smaller images than 890px wide. However,
only images which initial ratio is 1.78 are populated with `srcset`.
You said earlier that:
> The design of wp_calculate_image_srcset() is to only include the images
that match the aspect ratio of the image included in the src attribute.
So why, despite all my homepage `src` images being 890x500, they are not
all populated with srcset attributes?
Thanks for your insights
jb
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36154#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list