0

I've been at it a couple of days now and gotten Dianoga working, converting all of our "old media" images to shiny new webp format images. It works great for the standard ~/media url requests. I see that there is a separate ~/jssmedia set of services, and those are not working. Is there some other change in the configs I have to make, like the one in web.config, or anything else to make it work? I did find that I'm supposed to enable CDN support, which I did, but that made no difference. Ok, sorry, a teensy bit more info on this. We are on Sitecore 9.3 and attempting this with Dianoga 5.4.1.

Well, thank you in advance for any suggestions you can make.

1 Answer 1

1

For jss media you should override jss media handler and patch the same in the config

  public class ConvertImageToWebp : Sitecore.JavaScriptServices.Media.MediaRequestHandler{

  protected override bool DoProcessRequest(HttpContext context, MediaRequest request, Media media){
    
  if ((context?.Request.QueryString?["extension"]?.Contains("webp") ?? false) || (!Helpers.CdnEnabled && context.BrowserSupportsWebP()))
  {
    request.Options.CustomOptions["extension"] = "webp";
  }

  return base.DoProcessRequest(context, request, media); }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.