.MediaType of converted image resource does not change after conversion

The input is a png testo.png. I use .Resize to convert it into a webp. Before I convert, the image resource returns a MediaType of image/png as it should. After I convert, I expect the MediaType to be image/webp but instead it is still image/png. Am I missing something or is there something amiss?

{{ $image = .Page.Resources.GetMatch $imagePath }} <!-- $imagePath is images/testo.png -->
{{ $imagePostProcess = $image.Resize "970x webp q100" }}
{{ print $image.MediaType }} <!-- image/png -->
{{ print $imagePostProcess.MediaType }} <!-- image/png -->
{{ print $image.RelPermalink}} <!-- /blog/post-1/images/testo.png -->
{{ print $imagePostProcess.RelPermalink}} <!-- /blog/post-1/images/testo_hu4cc21e7a863615a92cd0655f577c12f3_800270_970x0_resize_q100_h2_box_3.webp -->

You can see the MediaTypes don’t change but the RelPermalinks do point to different files.

So how can I get the MediaType to change for the webp processed image?


Thank you! Glad to know I wasn’t missing something!

This was fixed this morning with https://github.com/gohugoio/hugo/pull/9789, available in the next release.

Fixed in Release v0.97.1 · gohugoio/hugo · GitHub


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.