Adding query parameters for Image Optimization in a VCL snippet

Comments

2 comments

  • Dominic Fee

    Hi Stanlee,

    Here you go:

    if (req.url.ext ~ "(?i)^(gif|png|jpe?g|webp)$") {
      set req.url = regsuball(req.url, "([\?|&])w=", "\1width=");
      set req.url = regsuball(req.url, "([\?|&])h=", "\1height="); 
      set req.url = querystring.set(req.url, "fit", "crop");
      set req.url = querystring.set(req.url, "auto", "webp")
    }
    

    If that doesnt work, have you followed the setup instructions?

    Thanks Dom

    0
    Comment actions Permalink
  • stanleegoodspeed

    Thanks Dom! That regex did the trick!

    0
    Comment actions Permalink

Please sign in to leave a comment.