I’m working on adding some responsive images to my hugo site, but I’m struggling with outputting the srcset
attribute correctly. Consider this example:
{{ $1x_image := "http://example.com/1x.gif 320w" }}
<img src=".." srcset="{{ $1x_image }}" />
No matter what I try, safeURL
, safeHTML
, replace "%20" ""
etc., it always seems to output:
<img src="..." srcset="http://example.com/1x.gif%20320w" />
Is this what the disabled safeHTMLAttr
would be used for? Or is there another way?
Note, I have flexibility in defining $1x_image
variable, but I’d like to avoid something like this:
{{ $1x_image_src := "http://example.com/1x.gif" }}
{{ $1x_image_width := "320w" }}
<img src=".." srcset="{{ $1x_image_src }} {{ $1x_image_width }}" />
Thanks!