Skip to content
Website Maintenance

WordPress Media Library Cleanup: Doing It Safely

Media libraries only ever grow. Every draft that was abandoned, every logo variant, every product photo replaced by a better one, every image uploaded twice because nobody could find the first copy. None of it is ever deleted, because deleting things is scary and nothing forces the issue.

A WordPress media library cleanup is worth doing for one specific reason, and it is not tidiness.

Why it actually matters

The uploads folder is usually the largest part of a WordPress site by a wide margin — larger than the database, larger than the theme and plugins combined. Everything downstream inherits that size.

Backups take longer and use more storage. Restores take longer, which matters most on the day you need one. Migrations become slower and more likely to time out. And on hosting with a storage limit, the uploads folder is what quietly fills it.

What it does not do is speed up your pages. An unused image sitting on the server is not loaded by anybody. Anyone telling you a media cleanup makes the site faster is describing image optimisation, which is a different job covered in image optimization for websites.

Remember that one upload is not one file

This surprises people and it changes the numbers considerably. When you upload an image, WordPress generates several resized copies — thumbnail, medium, large, and whatever sizes your theme registers. A theme can easily add four or five more.

So one photo can be eight files on disk. A library with two thousand uploads may hold well over ten thousand files. It also means an old theme you stopped using may have left thousands of resized copies in sizes nothing on the site requests any more.

Finding what is genuinely unused

Deciding what to delete is the difficult part, and it is where cleanups go wrong. Nothing in WordPress tells you whether an image is in use, so to delete unused images WordPress needs a plugin that scans for references.

Plugins that find unused media work by scanning post content and metadata for references. That catches most cases and misses several important ones: images set through a page builder, images referenced in theme options, images used in a slider or gallery plugin that stores its own configuration, and images used in CSS rather than in content.

An image can be very much in use and still look unused to a scanner. That is why the safe routine matters more than the tool.

The safe routine

  1. Back up the site, and specifically the uploads folder. Confirm the backup includes it — some configurations exclude uploads to keep backups small, which is exactly the wrong thing on the day you need to undo a cleanup.
  2. Run the scan and read the list rather than approving it. Look for anything you recognise as being on a live page.
  3. Delete in small batches, oldest first, then click through the site — the homepage, a service page, a product page, the header and footer on a phone.
  4. Wait a week before the next batch. A missing image on a page nobody visits daily takes a while to notice, and a week between batches means you can tell which batch caused it.
  5. Deal with the old theme sizes separately. Regenerating thumbnails after removing an unused theme reclaims a surprising amount without touching a single original.

What to leave alone

Anything you cannot place. Anything uploaded in the last few months. Anything that looks like a logo, a favicon or a social sharing image — those are often referenced in settings rather than in content and are the classic false positive.

And do not delete originals to save space. If a full-size image is too large, replace it with a properly sized version rather than removing it; deleting the original leaves the site with no source to regenerate from.

Preventing the next accumulation

Three habits keep the library from returning to where it was. Resize images before uploading rather than after. Delete the old file when you replace an image instead of uploading a second copy. And name files something you will recognise in a year, because the reason nobody deletes anything is that nobody can tell what any of it is.

Annually is often enough for this one — it is slow-moving, and there is no urgency. It sits with the other jobs that never become pressing, which is exactly why the housekeeping side of maintenance tends to happen only when somebody else is responsible for it. Our website maintenance checklist has it in the annual section.

Is Your Website Working Properly?

Get a free website health check from WebMaintor. We'll review your website's speed, security, forms, and technical health — and tell you exactly what needs attention.

No obligation. No automated reports. A real review by our team.