Using ShortPixel Image Optimizer with Cloudflare's API Token
ShortPixel Image Optimizer allows you to use the secure Cloudflare API Token on its settings instead of the Global API Key and Cloudflare account e-mail. This integration will allow our plugin to update your images on Cloudflare as soon as they are optimized so that Cloudflare will never serve unoptimized images.
To create a Token that is suited for this, you need to grant it the " Cache Purge" permission. Follow the instructions below to create it:
- Log in to your Cloudflare account, click the user icon in the navigation menu, and then My Profile.
Select API Tokens on the left menu and then press the Create Token button.
Scroll down and click the Get Started button next to Create Custom Token tab.
Under the Token name, give the token an internal descriptive name, such as "ShortPixel".
Under Permissions, select " Zone" > "Cache Purge" > "Purge" in the three dropdown menus.
If you see " Edit" instead of " Purge" under the third dropdown menu, you can select this option instead.
Under Zone Resources, select " Include" > "Specific zone" > "Your Domain" in the three dropdown menus. Note that your site must be added to your Cloudflare account for the domain to appear in the third dropdown, as seen in the screenshot below.
If you have multiple websites, you have two options: either click the " + Add more" link to add the domains you wish, or choose " All zones" from the second dropdown menu if you want to create the token for all your websites at once.
- Scroll down and press Continue to summary and then the Create Token button.
Copy the token generated. Make sure you save it because it will not be displayed again.
Paste the token code in our plugin settings ( Settings > ShortPixel > Cloudflare API > Cloudflare Token).