I am trying to use Cloudflare’s image resizing and converting images to AVIG/WEBP on dynamically but struggling to get it to work.
Within WordPress I was able to change all my image URLs to include /cdn-cgi/image/f=auto,quality=85/ therefore the final image URL becomes example.com/cdn-cgi/image/f=auto,quality=85/wp-content/uploads/image.jpg
However I quickly noticed this also converted .SVG images which aren’t compatible with Cloudflare image resize and the request fails.
Can anyone help me write a worker script that will add /cdn-cgi/image/f=auto,quality=85/ into the image path as shown above however only do this for .JPG, GIF, PNG. JPEG?