Found a weird way to mitigate reflow (caused by responsive images with lazy load) using the filter feature and decided to share.
Basically, I’m using the new filter feature to generate a “blank” placeholder. Instead of being a 1x1 GIF/PNG in base64, it’s “proportional” to the image (where I only know the width):
As the CSS, a simple img { width: 100% } or whatever the size you want to use should be enough. It’s just to enlarge the placeholder to the proportion of the image yet to load.
So far it was the laziest way I found to minimize reflow caused by images with variable height. It should be compatible with most lazy load JS libs out there. No inline style or more than a simple CSS rule.
To reduce the reflow even more (or avoid completely) you could increase the placeholder width, but also getting a longer base64.
And I’m not entirely sure, but maybe the size could be reduced with a (not available yet) convert function, using a PNG or GIF here.
This has the benefit of eliminating reflow without resorting to the somewhat limiting CSS padding-ratio calculation (which works best for images that have the same ratio).
I’m currently testing it out.
Thank you.
However note that in the next version of Hugo you will be able to convert an image to another format with this syntax: $placeholder := (.Resize "8x gif") or (.Resize "8x png")