Using Cloudflare Image Resizing for local dev work

Hi, thanks in advance if anyone can help. I am trying out Cloudflare Image Resizing (URL version), which is all working nicely on my staging site. makes things pretty easy.

I am using Wordpress and MampPro on my local machine to do the dev work. But how do i get it work locally, as Cloudflare is not serving the images as its locally. Surely Cloudflare must gave thought about this?

I am using the following and <?php echo $image[0]; ?> gives me the url of the full size image in wordpress.

/cdn-cgi/image/f=auto,width=320,quality=50,onerror=redirect/<?php echo $image[0]; ?>

Any help appreciated.



1 Like

Since you’re on localhost and bypassing Cloudflare’s network, there’s not really a great way to do this without just handling it yourself unfortunately.

We have a catch-all route in our application in dev mode for example that handles all URLs with the pattern /^\/cdn-cgi\/image\/(?:[A-Za-z]+=[\dA-Za-z]+,?)+\/(.*)/, and then routes them appropriately. It’s not perfect, but it lets us develop locally without broken images.


Thanks so much for coming back to me. Its seems a massive fail by cloudflare to not think of this. I don’t know many devs who work online when developing a site. I think i will need to do a test to see if i am on local environment and swap out the paths.

Thanks again

This topic was automatically closed after 15 days. New replies are no longer allowed.