'w' descriptor is invalid

Created on 3 February 2016, over 8 years ago
Updated 14 September 2023, 10 months ago
Failed parsing 'srcset' attribute value since its 'w' descriptor is invalid.

Dropped srcset candidate ....

I was getting tons of these errors in console about 'w' descriptors being invalid. When I set up all the image styles I used floats for the image scale and crop sizes. Then when the srcset fallback is set it becomes something like

<img class=" lazyloaded" srcset="...... 1353.6w" alt="" title="">

It turns out that 1353.6w is invalid.

So in the picture.module there are 3 places the width gets used to create the w descriptor, i changed them to round(width) and all the errors disappear straight away.

...
'width' => round($dimensions['width']) . 'w',
...
$srcset[$dimensions_clone['width']] = _picture_image_style_url($image_style_name, $variables['uri'], $variables['timestamp']) . ' ' . round($dimensions_clone['width']) . 'w';
...
$srcset['width'] = round($dimensions_clone['width']) . 'w';
...
πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand sphism

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