liamfiddler / eleventy-plugin-lazyimages

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

Img tags with width and height attributes. #19

Closed fragosti closed 4 years ago

fragosti commented 4 years ago

I sometimes use mark-up like

<img src="..." alt="..." class="..." width="300px"/>

But this plugin replaces the width specified in the markup. Is it possible to disable this? Maybe if the original mark-up specifies both it shouldn't be required to derive it from the file (or better, allow the markup to only specify one, determine the ratio from the file, and use that to derive the other value)

liamfiddler commented 4 years ago

👋 Hi @fragosti !

There currently is no way to disable that feature, but I agree it could be useful!*

The closest I can think of might be to set your selector config to img:not([width]), but that would disable this plugin entirely for those images.

* I'll add it to my list of features for the next release (or it would make a great first issue for someone to contribute to the project 😄)

fragosti commented 4 years ago

What actually ended up working pretty well was to use the style property instead, although it feels a bit hacky.