I coded an image optimization helper called sharp-watch that generates metadata for images including their aspect ratio and blurhash.
I would like images to be responsible which works by default for img
tags (when width is set to 100%
, height is set using image aspect ratio).
Problem is the aspect ratio is only know once image is downloaded. Given I know the aspect ratio ahead of time (using sharp-watch
metadata), is it possible to set width to 100%
and height using aspect ratio from metadata using CSS (not JavaScript)?
I need to set the height to display blurhash while image loads.