Feature Request: data-background-image responsive images with data-srcset
See original GitHub issueCurrently I use various media queries to include a different background image as needed, and being able to apply lozad to achieve the same result would be great 😃.
I wish you could define various background images per screen size in the same way you can for responsive images:
<!-- background image example -->
<div class="lozad" data-background-image="image.png" data-srcset="image.png 1000w, image-2x.png 2000w">
</div>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:17
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Responsive images - Learn web development | MDN
Objective: Learn how to use features like srcset and the <picture> element to implement responsive image solutions on websites.
Read more >Lozad.js - Apoorv Saxena
Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more.
Read more >A Guide to the Responsive Images Syntax in HTML - CSS-Tricks
This guide is about the HTML syntax for responsive images (and a little bit of CSS for good measure). We'll go over srcset...
Read more >Lozad NPM | npm.io
allows lazy loading of dynamically added elements as well,; supports <img>, <picture>, iframes, videos, audios, responsive images, background images and ...
Read more >Responsive Images - A Reference Guide from A to Z
High-resolution displays have a higher pixel density. This means more pixels in the same amount of physical space. As a result, high-resolution displays...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also needed this, so got a version of it working.
I can now pass in
data-background-image-md
,data-background-image-lg
, etc, depending on breakpoint values that I define in the JS.You need to re-write load from the original, the only thing changing here is this section;
If there is a better way to overwrite something in the existing
load()
function that would be helpful.The rest remains as is, full example below;
we can document custom loading function to implement this behaviour to start with