I’d like to request a little feature to add an image’s width and height to Hugo’s HTML output automatically. This is especially relevant for Retina images. Since Retina assets end with _2x
by convention (or @2x
, although the former is considered preferable), the dimensions should be halved whenever the 2x
suffix is encountered. (And if the name ends in _3x
or @3x
divide by 3, etc.)
This would be an easy way to add Retina image support to Hugo by default. (That said, it’s far from the only way to do so, and it has the disadvantage of loading bigger files on non-Retina devices.)
For now I’ll just write a separate script to process Hugo’s output folder, search for <img>
tags, get the dimensions, correct for _2x
assets, and finally add the correct width
and height
attributes.