danielfdickinson / image-handling-mod-hugo-dfd

A Hugo module for handling images and image-related functionality for themes
https://www.image-handling-mod.wtg-demos.ca
MIT License
17 stars 7 forks source link

Lack of LQIP background #65

Closed mesetka closed 1 year ago

mesetka commented 1 year ago

This awesome module lacks 1 modern option - LQIP background generation for images. There are two ways of implementing this - either adding Base64-encoded low quality image (seems best option for now is blurred x20 webp with quality 30) as background by style, or with newly implemented Hugo image processing option - .Colors, which will find image's most frequently used colors, so a background gradient could be added to image style (less bytes will go to html and processing should also be faster, but the background could differ more from the image, than Base64 webp will bring). So I would like to start a bit of discussion, which way is better, which part of the module should process this (thumbnail-or-full-picture for adding style/class and generate-images for actual processing? or a separate partial, quite similar to generate-images, but doing just one job - producing LQIP?). Should this option go as default for lazy-loaded images, or should user decide, if he wants to use that function?

danielfdickinson commented 1 year ago

I'm wondering if this should use .Colors as a background gradient AND also have a base64-encoded low quality image, per https://github.com/bep/gallerydeluxe / https://github.com/gohugoio/hugo/releases/tag/v0.104.0 / https://discourse.gohugo.io/t/hugo-0-104-0-released/40654/6?u=cshoredaniel.

I'd think the .Colors would be a separate partial (since the module currently doesn't generate CSS, and would be called from the stylesheet processing), and the low quality webp would be part of the img tag and attribute generation.

Does that seem reasonable?

I also like the idea of opt-out rather than opt-in (that LQIP as default that can be disabled).