Image processing in content file

I’ve got a situation where I’d like to use Hugo’s image processing to resize and encode images I’ve included in page bundles. I’m currently using the figure shortcode to include them, and sizing them using the width attribute, but I’d ideally like to resize and encode the images before passing them to that shortcode.

What’s the best way to do this? I could make my own version of figure with an additional optional resize parameter? If that’s the answer is there some way to extend the existing code rather than copying the source?

Also wondered about writing a shortcode to wrap around the figure shortcode, but I don’t think that can work because I’ve read that the inner shortcode gets evaluated first?


I have a figure shortcode in my Zen theme that handle files both in assets and in static, resizing and some other stuff.


Here’s a post about what I use, albeit not using picture and img rather than figure:

. . . with the full code currently at: