ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 245 forks source link

LazyLoad on multiple elements with both default and non-default sources and attributes #106

Open niklasquitzau opened 7 years ago

niklasquitzau commented 7 years ago

I am using LazyLoad XT to load default <img>s and it's working just fine using

$.extend($.lazyLoadXT, {
    selector: 'img',
    srcAttr: 'src',
});

I am using the srcAttr: 'src' due to compatibility with a third party plugin which requires the default src. However, I have several divs with a background-image that I would like to Lazy Load. My question is; how do configure the plugin to also target a div with fx .someClass to lazy load the background-image with the default attr data-bg? I've tried several different variations which always seem to cancel the other one out. So the back-ground image will work but then not the <img> etc. Furthermore I have an HTML5 video running that I would like to lazy load but with the default src instead of data-src.

Basically, I would like to know how to define each element that I would like to lazyload, based on fx class, and also the src attribute whether it's the lazyload default or the html default.

Sorry for the noob question, hope someone can help.