diff --git a/js/lazyload.js b/js/lazyload.js index 73789e73..b4c1fcc5 100644 --- a/js/lazyload.js +++ b/js/lazyload.js @@ -68,7 +68,8 @@ function getCellLazyImages( cellElem ) { } // select lazy images in cell var lazySelector = 'img[data-flickity-lazyload], ' + - 'img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]'; + 'img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset], ' + + 'source[data-flickity-lazyload-srcset]'; var imgs = cellElem.querySelectorAll( lazySelector ); return utils.makeArray( imgs ); } @@ -96,7 +97,9 @@ LazyLoader.prototype.load = function() { this.img.getAttribute('data-flickity-lazyload-src'); var srcset = this.img.getAttribute('data-flickity-lazyload-srcset'); // set src & serset - this.img.src = src; + if ( this.img.tagName.toLowerCase() === 'img' && src ) { + this.img.src = src; + } if ( srcset ) { this.img.setAttribute( 'srcset', srcset ); } diff --git a/test/index.html b/test/index.html index 8e6a9160..1579b649 100644 --- a/test/index.html +++ b/test/index.html @@ -55,6 +55,7 @@ + @@ -239,6 +240,21 @@

lazyload srcset

+

lazyload picture source srcset

+ +

groupCells