2026年11月14日
2026年11月14日
ShortPixel Setup: Compress WordPress Images and Convert to WebP/AVIF
This article is a localized edition of the Japanese original. Read the Japanese original
ShortPixel Image Optimizer is a plugin that compresses your WordPress images on ShortPixel's servers and replaces the images on your site. It can also create and deliver WebP and AVIF images. This article covers everything from the initial setup to bulk processing existing images and restoring them.
Screen names match ShortPixel Image Optimizer 6.6 as of November 2026. According to wordpress.org, it requires WordPress 5.9 or later and PHP 7.4 or later. This article uses the plugin's English screen labels, with an explanation for each.
Check how pricing works (credits) first
ShortPixel uses one "credit" for each image it processes. According to the plugin description on wordpress.org (as of November 2026):
- Up to 100 credits per month are free. Once you exceed them, processing pauses until the next month or until you buy a plan
- WordPress creates several sizes (thumbnails) from each image. Each thumbnail also uses a credit, so one upload can use several credits
- If you enable WebP or AVIF creation, each image and thumbnail uses an additional credit for each format (except on the Unlimited plan)
- Images that shrink by less than 5% do not use a credit
Pricing and plan details can change, so check the official ShortPixel website before buying. AVIF creation is not available with some license types (the settings screen tells you if so).
Step 1: Install and register the API key
- In the admin screen, go to "Plugins" → "Add New Plugin", search for "ShortPixel", then install and activate ShortPixel Image Optimizer.
- Open "Settings" → "ShortPixel".
- If you do not have an API key, enter your email address in the form on the screen and submit it, and a key is created. If you already have one, paste it into the API key field and validate it. The API key is 20 letters and numbers.
To install it with WP-CLI, do the following (the slug uses the British spelling optimiser).
wp plugin install shortpixel-image-optimiser --activate
If you see "API Key is valid but your site is not accessible from our servers", ShortPixel's servers cannot fetch your images because of Basic authentication or IP restrictions. Processing may fail on staging or local environments.
Step 2: Choose the compression type and size (Image Optimization tab)
Under "Compression type", choose one of three methods.
| Method | Description (summary of the settings screen) | Best for |
|---|---|---|
| Lossy | Highest compression. Recommended for most sites. Looks almost identical to the original | Blog and product photos |
| Glossy | Compresses while keeping quality very close to the original | Photography and other images where quality comes first |
| Lossless | Compresses without changing quality. Saves less | Diagrams and screenshots |
If you are unsure, process a few of the same images with Lossy and Glossy and compare how they look and how big they are. You can also reprocess with a different method from the ShortPixel column in the Media Library (this needs the backup in Step 6).
The same tab also has these settings:
- Optimize Thumbnails: also compresses thumbnails. It helps page speed but uses more credits
- Remove EXIF: removes metadata such as the date taken, camera and location. It also keeps location data from being published
- Resize large images: shrinks original images that are larger than the width and height you set. It makes a big difference on sites that post large smartphone photos as-is, but it changes the resolution of the original file, so enable backups before using it
Step 3: Decide on backups and processing (Processing tab)
- Backup original files: saves the images before optimization to
/wp-content/uploads/ShortpixelBackups/so you can restore them later. Enable it if you might redo processing with a different method. It uses that much more server space - Smart backup: backs up only the original (main) image and regenerates thumbnails when restoring. It saves space
- Automatic backup cleanup: automatically deletes backups older than the period you choose
- Optimize media on upload: automatically optimizes images when they are uploaded
- Background mode: continues bulk processing even when the browser screen is not open. The screen notes that processing may pause when your site has no visitors
If you delete the backup folder, you can no longer restore images or reprocess them with a different method.
Step 4: Create and deliver WebP and AVIF (WebP/AVIF & CDN tab)
Checking "Create WebP Images" and "Create AVIF Images" makes the plugin create WebP and AVIF images when it optimizes. Creating them alone does not get them to visitors, so you also choose a delivery method.
| Delivery method | How it works | Caveats |
|---|---|---|
| Using the PICTURE tag syntax | Wraps the page's img tags in picture tags and gives AVIF or WebP to browsers that support them |
The HTML structure changes, so some themes' CSS or JavaScript may break the layout. Check the display after enabling it |
| Without altering the page code (via .htaccess) | Writes rewrite rules to Apache's .htaccess and returns WebP or AVIF at the same URL to browsers that support them |
For Apache. It cannot be enabled if .htaccess is not writable |
| Delivery through the ShortPixel CDN | Serves images through ShortPixel's CDN | Image URLs change to CDN URLs |
The rules written by the .htaccess method return the .webp (.avif) file with the same name when the Accept header sent by the browser includes image/webp (or image/avif) and that file exists. They also add a Vary: Accept header so caches do not mix up the formats.
Nginx does not read .htaccess, so you need equivalent rules in the server configuration. If you cannot change the server configuration, choose the PICTURE tag or CDN method.
To check that delivery works, look in the "Network" tab of the browser's developer tools and see whether the image "Type" is webp or avif. If you use a page cache or CDN, clear the cache before checking. For an overview of WebP conversion methods, see how to convert WordPress images to WebP.
Step 5: Bulk-process existing images
- Open "Media" → "Bulk ShortPixel".
- Check the number of target images and the estimated credits needed. If you run short, processing stops partway.
- Start processing. If you do not use Background mode, keep this screen open until it finishes.
Rather than processing everything at once, it is safer to first process a few images individually in the Media Library, check how they look and how much they shrank, and then move on to bulk processing. How to run bulk processing and what to check when it stops are explained in detail in steps and caveats for bulk-optimizing existing images with ShortPixel.
Process with WP-CLI
ShortPixel Image Optimizer provides the WP-CLI command wp spio.
# Run bulk processing automatically, from creating the queue to finishing
wp spio bulk auto
# Optimize the image for attachment ID 123
wp spio add 123
# Show the status, such as the number of pending items
wp spio status
# Restore attachment ID 123 from its backup
wp spio restore 123
You can check the available options with wp help spio and wp help spio bulk.
Step 6: Restore the original images
Images processed with backups enabled can be restored.
- One at a time: switch "Media" → "Library" to list view and restore from the actions in the ShortPixel column
- All at once: on the "Bulk ShortPixel" screen, choose the option to restore the whole Media Library
- WP-CLI: specify the ID, as in
wp spio restore 123
Restoring does not use credits. Images without a backup cannot be restored from ShortPixel, so restore them from your site backup.
Notes
- Back up the whole site before you start.
- Use only one image optimization plugin. Compressing twice with another plugin can lower quality or cause conflicting WebP delivery settings.
- CDNs and caching plugins also have WebP delivery features. Decide on a single place to deliver from.
- If you see errors, see how to fix ShortPixel errors.
Summary
- ShortPixel is credit-based. Thumbnails and WebP/AVIF each use credits too, so estimate the count before you start
- Choose Lossy, Glossy or Lossless, and decide by comparing a few images
- Enable original-image backups if you might redo processing
- Do not just create WebP/AVIF; choose whether to deliver them via PICTURE tags, .htaccess or the CDN. .htaccess does not work on Nginx
- Bulk-process with "Bulk ShortPixel" or
wp spio bulk auto, and restore from the ShortPixel column or withwp spio restore
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)