This is the last part of the series. We have chosen formats, set upload dimensions, tidied generated sizes, aligned responsive images and lazy loading, and covered vectors and video. Yet after a few years of operation, even with all those rules observed, files nothing references pile up: drafts, replaced banners, one-off material.
The hard part is proof, not deletion
Being confident that “nothing uses this file” is harder than it sounds, because references are scattered.
Images inserted into content are straightforward. The lower rows are the problem — especially URLs inside CSS and references a page builder has stored inside its own data structure, which ordinary searching rarely catches. Add one more case: files linked directly from a newsletter or another site. Nothing on your site uses them, but deleting them breaks somebody else’s screen.
A safe order — quarantine before you delete
Back up first: the uploads folder together with the database, and if you can, restore it once to confirm. A backup you have never restored is not a backup.
Next, the candidate list. Whether by tooling or direct queries, assemble the set of files for which no reference was found. Treat it as a list of suspects, not a deletion list — the lower rows of the table above guarantee false positives.
So you quarantine. Move them to a separate folder rather than deleting, and watch the site for a few weeks. A missing image is conspicuous, and the server log records 404 requests for anything still being asked for. That observation window is the single most important step in the procedure. If nothing surfaces, then delete.
Rules that stop it accumulating again
Cleanup is never a one-off. To keep it from returning you have to adjust the habits. Do not upload review drafts to the media library — review them in the team’s own storage. When replacing an image, update the existing file rather than uploading a new one, so the URL survives and no orphan is left behind. And an agreed file naming convention means you can still tell what something is years later.
Closing the series
Across eight parts one point has held throughout: making images lighter is not the same as giving up quality. Choosing a format that matches the nature of the artwork, generating only the sizes you use, handing the browser accurate material to choose from, and treating exactly one first-screen image as the exception — all of those protect the design while reducing the weight. WordPress already ships responsive images and lazy loading by default. Our job is simply to give those defaults something correct to work with.
Wider performance topics continue in the performance archive, and the operational side of cleanup work in the development workflow archive. To overhaul the image pipeline, caching and server configuration as one job, there is our optimization program — and the order we work in, along with what we measure before and after, is published on the process page.