Clean up your media library without losing files
No panic backup
Why your media library is getting out of control
Step-by-step plan: cleaning up your library in practice
Create a backup and test on staging first
Map out your library
Delete only what's truly unused
Compress and convert what remains
Process in batches and verify the results
Comparing formats: what you compress into what
| Format | Typical savings compared to original | When to use |
|---|---|---|
| AVIF | Often the smallest files; up to 94% smaller than the original in our tests. | Modern browsers, photos with lots of detail. |
| WebP | Significant savings with broad support; typically 25 to 50 percent smaller than a comparable JPEG. | Wide fallback option if you're not fully switching to AVIF yet. |
| JPEG (optimized) | Smaller gains than AVIF or WebP, but universally compatible. | Legacy systems, email attachments, print preparation. |
| PNG | Compression helps, conversion doesn't always; PNG remains necessary for transparency. | Logos, icons, screenshots with sharp text. |
Common mistakes when cleaning up
- Deleting files that are still embedded somewhere, resulting in broken images.
- Not creating a backup before starting a large cleanup operation.
- Working directly on the production environment instead of testing on staging first.
- Setting compression quality too aggressively without visually checking the images.
- Not clearing the cache after a batch run, so visitors still see old files.
- Leaving old, unused thumbnail formats from a previous theme behind.
Frequently asked questions
No, not if you follow the steps in this guide. Compression changes a file, it doesn't delete it. Only files you deliberately delete will disappear. For safety, always test on staging first.
You don't have to, and with a large library, it's often not practical either. Batch processing, rolled out gradually in the background, is safer and puts less strain on your server than doing everything at once.
You can, but the gains are usually minimal. Double compression adds little and can result in noticeable quality loss if the settings are too aggressive.
Spark Media Optimizer works with safe copies and accounts for rollback, so if you're unsure, you can always revert to the original state.
Compare the total storage of your media library before and after the cleanup, and check your page speed with a tool like Lighthouse or PageSpeed Insights.
Yes, the same approach applies to web shops. For shop-specific considerations, see our page on optimizing WooCommerce images.