Reuse URL to resized image

My image resize function make this output:

<img srcset="/imagefile-g29405233a_hubf65b9bcd30afee0a28638d2f21fe191_100160_300x0_resize_q75_box.jpg 300w, /imagefile-g29405233a_hubf65b9bcd30afee0a28638d2f21fe191_100160_600x0_resize_q75_box.jpg 600w, /imagefile-g29405233a_hubf65b9bcd30afee0a28638d2f21fe191_100160_1200x0_resize_q75_box.jpg 1200w" sizes="(max-width:480px) 300px, (max-width:768px) 600px, 1200px" src="/imagefile-g29405233a.jpg" alt="title">

I use page budle, so main image is uder post directory and resized images are under "resources > _gen > images > posts > post-title > postresized-images.jpg

How can I access e.g. 600w image URL to use this in other parts of the theme with {{ . }} ?
Hugo adds some hash number to resized image’s name so hardcoding URL isn’t possible.

You don’t reference stuff in resources, it is just the cache
If you use .Resize on the same image with the same parameters it will produce a link to the exact same image.

1 Like