Make aspectratio's width 100% specific to lazyloaded images

Created on 6 May 2016, about 8 years ago
Updated 19 September 2023, 9 months ago

as noted by @titouille after https://www.drupal.org/node/2491101 β†’ was closed, the aspectratio css is too broad.

Just a little question about the lazyaspectratio... ls.aspectratio.css contains the following rule :

picture img {
  width: 100%;
}

With this rule, when aspectratio is used on at least one picture on the page, ls.aspectratio.css is loaded and apply the rule on all pictures on the page, even if it's not needed (for example pictures as thumbnail in the main content are stretched and pixelised). With this behavior, themer is obligated to add lot of rules to correct the width for any pictures that doesn't need 100% width.

Why don't use a more precise rule like this :

picture img.lazyaspectratio {
  width: 100%;
}

To apply the 100% width only to pictures that need it for the aspect-ratio calculation ? If themer want to apply 100% width to any pictures, I think it's his choice. he doesn't must be obligated to do when enabling the picture module, I'm right ??

Thanks in advance for your answer about that.

The attached patch simply changes the css to:

picture img.lazyload {
  width: 100%;
}
πŸ› Bug report
Status

Closed: duplicate

Version

2.0

Component

Code

Created by

πŸ‡ΏπŸ‡¦South Africa duncan.moo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024