How to use Cloudflare with ShortPixel Adaptive Images
If you want to use Cloudflare as your CDN when using ShortPixel Adaptive Images, instead of ShortPixel's CDN, follow these steps:
- Log in to your Cloudflare account.
- Select your website and then the DNS section from the side menu.
- Think of a name for the subdomain from which you want the images to be delivered. For example, if your domain is mywebsite.com, you could choose
img
.mywebsite.com. - Following the previous example, add a new CNAME record from
img.mywebsite.com
tono-cdn.shortpixel.ai
:
Remember that
mywebsite.com
should be changed to your actual domain, and thatimg
should be changed to something else if it's already used by another CNAME, likeimages
.mywebsite.com ormedia
.mywebsite.com
Important! The small cloud must be orange in order for you to use the CDN features offered by Cloudflare. -
Wait 5 minutes for Cloudflare to complete all the technical tasks in the background.
-
Take any image URL from your site, append it to
https://img.mywebsite.com/spai/q_lossy+ret_wait/
and make sure that the new URL can be accessed. Example:- If your website is called mywebsite.com, your new CNAME on Cloudflare is
img.mywebsite.com
, and your sample image ishttps://www.mywebsite.com/wp-content/uploads/2022/04/image.jpg
, - try calling this URL:
https://img.mywebsite.com/spai/q_lossy+ret_wait/https://mywebsite.com/wp-content/uploads/2022/04/image.jpg
- Can you view it without errors? Continue with the next step.
- If your website is called mywebsite.com, your new CNAME on Cloudflare is
-
Go to Settings > ShortPixel AI > Behaviour and enter
https://img.mywebsite.com/spai
in the API URL field- Replace
mywebsite.com
with your actual domain name. - Replace the
img
part if your subdomain is different, like configured above.
- Replace
- Clear the CSS cache from ShortPixel AI's settings:
Clear your WordPress cache: How to clear WordPress cache