From 98efb8c9924831a176a53eb370f1e9eacc1483a9 Mon Sep 17 00:00:00 2001 From: Alice Lawrie Date: Thu, 30 Jun 2022 15:48:37 -0400 Subject: [PATCH] feat(imgixtag): optional class nolazyload to selectively disable lazy loading Added support for a new optional class 'nolazyload' that when use will selectively disable lazy loading for that element while using lazysizes. --- src/ImgixTag.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ImgixTag.js b/src/ImgixTag.js index 7160c5d0..c35a7dce 100644 --- a/src/ImgixTag.js +++ b/src/ImgixTag.js @@ -45,6 +45,15 @@ var ImgixTag = (function () { this.baseUrl = this._buildBaseUrl(); this.baseUrlWithoutQuery = this.baseUrl.split('?')[0]; + //manual override to use sizes, srcset, and src when lazyloading + if(util.isString(this.el.className)){ + if (this.el.className.includes("nolazyload")){ + this.settings.sizesAttribute = "sizes"; + this.settings.srcsetAttribute = "srcset"; + this.settings.srcAttribute = "src"; + } + } + if (util.isString(this.settings.sizesAttribute)) { this.el.setAttribute(this.settings.sizesAttribute, this.sizes()); }