Enhance aspect ratio handling by leveraging native width/height support on <source>
elements
#258
Labels
help wanted
Extra attention is needed
<source>
elements
#258
Bug description
Chrome, Firefox, and Safari now support setting the
width
andheight
attributes on<source>
elements within<picture>
elements. You can read more about this in the web.dev article on optimizing CLS. This enhancement allows browsers to better handle layout shifts and varying aspect ratios for responsive images.How to reproduce
Current Behavior:
Currently, Statamic Responsive Images does not take advantage of this browser capability. As a result, when multiple sources are provided, the appropriate
width
andheight
attributes are not applied to<source>
elements, which may lead to layout shifts due to varying aspect ratios.Proposed Enhancement:
Set appropriate
width
andheight
attributes on<source>
elements based on their aspect ratios.Benefits:
Environment
Installation
Fresh statamic/statamic site via CLI
Antlers Parser
regex (default)
Additional details
Leveraging native width and height support on
<source>
elements can lead to significant improvements in layout stability and overall performance on modern browsers. This enhancement would allow the package to better handle responsive images by using up-to-date browser capabilities.Thanks for considering this enhancement!
The text was updated successfully, but these errors were encountered: