liamfiddler / eleventy-plugin-lazyimages

Eleventy plugin that adds blurry placeholders & lazy loading to your images
MIT License
139 stars 29 forks source link

Disable lazy loading for certain images #59

Closed dimejo closed 2 years ago

dimejo commented 2 years ago

Is it possible to disable lazy loading for certain images by e.g. adding a class?

liamfiddler commented 2 years ago

👋 Hi Dimejo!

Yes, the imgSelector config option allows you to specify a selector for targeting which images get lazy loaded.

Using the :not pseudoselector we can ignore all IMG elements that have a class.

For example, the following will add lazy loading to all IMG elements except those with the class="ignore-lazy":

eleventyConfig.addPlugin(lazyImagesPlugin, {
  imgSelector: 'img:not(.ignore-lazy)',
});
dimejo commented 2 years ago

That's awesome, thank you so much!