Lazy loading not setting srcset attribute
The following mark-up only creates a src attribute for the image, and doesn't create a srcset:
<img
data-splide-lazy-srcset="/assets/img//banners/image-w360.jpg 360w, /assets/img//banners/image-w768.jpg 768w, /assets/img//banners/image-w960.jpg 960w, /assets/img//banners/image-w1200.jpg 1200w, /assets/img//banners/image-w2000.jpg 2000w" sizes="80vw"
data-splide-lazy="/assets/img//banners/image-w1200.jpg"
alt="Making buying flooring pleasurable"
class="desktopBanner"
>
The above results in the following (src is created but no srcset, causing it to load only the 1200px:
<img
data-splide-lazy-srcset="/assets/img//banners/image-w360.jpg 360w, /assets/img//banners/image-w768.jpg 768w, /assets/img//banners/image-w960.jpg 960w, /assets/img//banners/image-w1200.jpg 1200w, /assets/img//banners/image-w2000.jpg 2000w" sizes="80vw"
data-splide-lazy="/assets/img//banners/image-w1200.jpg"
alt="Making buying flooring pleasurable"
class="desktopBanner"
src="/assets/img//banners/image-w1200.jpg" style=""
>
Try it with this branch https://github.com/Splidejs/splide/pull/169
@tonyastley That seems to work fine: https://jsfiddle.net/8doz13hf/
I guess the script version is old.
@NaotoshiFujita There seems to be an issue with lazy loading srcset images if using cover: true as the background url is set to the default image src value as opposed to the appropriate srcset image.
https://jsfiddle.net/habitualshaker/pegxcLso/3/
If you inspect the html for the image you will see the background image is set to https://source.unsplash.com/random/600x300?sig=6 (which is the default value).
Lazyload does not work for different resolutions
Close the issue due to the major version update. Feel free to create a new issue or open a new discussion.
The cover option is not compatible with srcset lazy loading.