Hi @makobaby01
but how would I do it in code?
If you are talking about templates, you don’t have to if you continue using WebP express with alter HTML option enabled. It will automatically update the HTML for you.
Like using imagemagik (I can’t remember the name) which is a conversion via php to webp, would that also change for the case of cloudflare?
It is (in a way) the same functionality this plugin offers if you are talking about creating a PHP script to dynamically return image (or convert if WebP does not exist) based on browser support. The only advantage that I can think of is that you can actually create a page rule and exclude that script from server cache. But this would mean that you have to manage the conversion and basically update image URLs using filters. It is possible but then you also have to consider CSS & JS.
I would recommend you to read my other comment. I think you can use the service worker approach here for best results. That way, you don’t have to worry about Cloudflare edge cache rules, modifying HTML code or anything like that.