Can I use a different CDN with Autoptimize?

If you're interested in using a different CDN when serving optimized images from ShortPixel via ShortPixel Adaptive Images or Autoptimize, then please:

  1. Edit your DNS records and add a CNAME from to
    1. Replace "" with your actual domain name.
    2. If "" is already being used on your DNS records, you can change it for whatever you want, like "" or "".
  2. We need to replace the API URL on the plugin:
    1. If you're using ShortPixel Adaptive Images, have a look at the following document: Can I use a different CDN with ShortPixel Adaptive Images?
    2. If you're using Autoptimize, in your WordPress plugin add a code snippet (see the example below). To add a code snippet you can use a plugin like this one.

function use_my_own_cdn($urlIn) {
return str_replace("","",$urlIn);

Note: the filter name changed since version 2.5 of Autoptimize.


Here is a step-by-step example on how to set up the CNAME (previous step 1) on Cloudflare. Please notice that we are not responsible for any changes made by Cloudflare that would invalidate the following steps. Therefore, if you encounter any issues while creating your new CNAME in your DNS records, please contact your CDN or hosting provider.

  1. Enter your Cloudflare account
  2. Select the DNS tag from the top menu

  3. Add a new record following this example:

  4. "example-cdn" should be changed to whatever you wish, but make sure it is the same everywhere you set it up. Make sure the cloud is yellow so you can use the CDN features offered by Cloudflare.

Still need help? Contact Us Contact Us