Before Umbraco 17 we didn’t use HMACSecretKey, so we didn’t have a problem using a WebP Middleware which automatically checked if WebP was supported and appended the “format=webp” if it was.
But this is not the case anymore
So we have begun using HMACSecretKey, but of course this will "alter” the URL after the HMAC has done it’s magic and then invalidating the Image URL.
How have you solved it the “issue” with serving WebP and using HMAC?
I have a webp middleware and HMAC on 17 and I haven’t seen the issue, Umbraco passes the secret to ImageSharp.Web so everything is calculated at the correct time, at least in my experience.
Webp support is widespread, so honestly, we only serve webp images these days.
However, if you want to support non-webp browsers, why don’t you simply create an image source set in the html with multiple formats? I agree that the html will get a little bigger, but you let the browser decide what it supports and what the correct size is that is needs. That saves on middleware processing time.
FWIW @AndersBrohus , I was working on this exact task just yesterday and was experiencing the same results.
We started out a new project on 17.1
We’re now on 17.2.2 and always convert all of our images to .webp
I followed the imaging settings documentation and all the images resulted in a 404.
I finally reverted the effort because i didn’t get to a timely victory, sigh!
Of note - it did not occur to me to try any other image formats so I didn’t think it was an .webp issue specifically.
Started seeing a similar issue myself now but its fine if the image is using GetCropUrl(…) so all the media based images are happy, however just a url with no crops or querystring I hit the issue as the HMAC querystring is missing
I know nothing. But given the approach above, I ran into the same issue. Once you apply formatting commands, I suspect a HMAC is required. i.e., a request with no image-crop commands has no HMAC, but once you apply a command, an HMAC (and a valid one) is required.
Thanks to this discussion, I realized that my AutoFormatImagesToWebp package didn’t support the HMACSecretKey setting. I’ve released a new version that should fix this issue, but I need feedback from someone who isn’t using my machine!
(There’s a little more happening in my package that may not make it suitable for everybody.)