HomeExtensionsScriptsWordPressDocsSupport
WordPress pluginv1.2.0

Media Size Cleanup

Remove the image size files your theme no longer uses, rebuild the sizes you keep and clear out orphan files, with a backup you can restore.

This guide covers installing and using Media Size Cleanup by Quintaphon (version 1.2.0), a free plugin that removes image size files your site no longer needs, rebuilds the sizes you keep and finds orphan files in the upload folders. Use it for the first cleanup and as a reference for every screen.

Tip

The plugin lives under Media > Size Cleanup. It has four screens: Overview, Image sizes, Orphan files and Backups.

Overview

WordPress copies every uploaded image into each registered size. When you switch themes, change the sizes under Settings > Media or remove a plugin, the old copies stay on disk. Media Size Cleanup finds them and removes them in a safe order:

  • Scan: a dry run that lists every file it would remove, per size, with a CSV download.
  • Clean up: moves those files to a backup folder and rebuilds the sizes you keep with your current settings.
  • Restore: puts every file and the old size data back in one click.
  • Orphan files: files in the year and month upload folders that no media item uses.

Nothing changes until you start a cleanup, and every cleanup can be undone until you delete its backup.

Requirements

ItemNeeded
WordPress5.8 or newer (tested up to 7.1)
PHP7.2 or newer, with GD or Imagick for the rebuild
UserAn administrator (the manage_options capability)
DiskFree space for the backup, about the size the scan reports

Install

  1. Download media-size-cleanup.zip.
  2. In WordPress go to Plugins > Add New Plugin > Upload Plugin, choose the file, click Install Now and activate it.
  3. Open Media > Size Cleanup.

Activating the plugin changes nothing on your site. It only adds the screen for administrators.

Overview screen

The Overview shows the number of images in the library, how many sizes are registered (and how many come from the theme or plugins), the result of the last size cleanup and the space your backups hold. Below that it explains what each run removes, rebuilds and skips.

Media Size Cleanup Overview screen
Overview: images, sizes, the last run and the space held in backups.

Image sizes

The Sizes to keep table lists every size registered right now by WordPress, your theme and your plugins, with its width, height, crop and who added it. Turn off a size your theme does not use and its files are removed. Keep all turns every size back on.

Files of sizes that nobody registers any more, for example from an old theme, are not in the table and are always removed.

Image sizes table with a switch per size
Image sizes: medium_large turned off, the other sizes kept.

Check your theme first

Only turn off a size when you are sure nothing shows it. WordPress uses medium_large and the 1536 and 2048 sizes in responsive image markup, so keep them unless your theme says otherwise.

Options

OptionDefaultWhat it does
Rebuild the kept sizesOnCreates the kept sizes again with the current Settings > Media values. Needed after you change those sizes. Slower, since every image is resized.
Remove files with outdated dimensionsOnKept-size files whose width and height no longer match the current settings. With rebuild on, they are replaced by new ones.
Remove leftover size filesOnFiles on disk named like an image's sizes (photo-300x200.jpg) that its data no longer lists.
Skip files linked in your contentOnKeeps any file linked in posts, pages, custom fields or settings, so old articles keep their images.
Delete files permanentlyOffDeletes instead of moving to a backup. Needs DELETE typed in the confirmation and can not be undone.

The page remembers the sizes and options you used last.

Scan and clean up

  1. Click Scan (dry run). The scan reads every image and lists what it would remove, grouped by size and reason, with the total space. Nothing is changed. Download file list (CSV) gives the full list.
  2. Click Start cleanup. It is enabled only after a scan with the same sizes and options; change anything and you scan again.
  3. Confirm the dialog. The files move to a new backup, and with rebuild on, each image gets its kept sizes created again.
  4. Keep the tab open until the run finishes. Stop ends it after the current batch; everything done so far is in the backup.
Cleanup result with files moved to the backup per size
Cleanup finished: 110 files moved to a backup and 36 images rebuilt.

Large libraries

The work runs in short batches, so PHP time limits are never hit. A cleanup with rebuild on takes about as long as regenerating thumbnails. Only the tab that started a run can drive it.

Rebuild missing sizes

Rebuild missing sizes only creates the kept sizes for images that lack them, for example after you add a theme with new sizes. It removes nothing and needs no scan.

Orphan files

The Orphan files screen looks in the year and month upload folders (for example 2026/10) for files that are not an original, a size, a WebP or AVIF version or an editor backup of any media item. These are usually left behind when a delete did not finish, or were copied in by FTP.

  • Only the uploads/YYYY/MM folders are scanned; other folders in uploads are never touched.
  • Files changed in the last hour, hidden files and PHP files are skipped.
  • Keep files linked in your content (on by default) keeps a file that a post, page, custom field or setting links to.
  • Orphan files are always moved to a backup, never deleted straight away, and each file is checked again just before it moves.
Orphan files found in the upload folders
Orphan files: four files no media item uses.

Backups and restore

Each cleanup and each orphan move creates a backup in wp-content/uploads/media-size-cleanup-backup/. It holds the moved files in their original folder layout, plus each image's old size data. The Backups screen lists them with the date, type, number of files and size.

  • Restore puts every file back and gives each image its old size data. If a file can not go back, for example because a new file now has its name, the backup is kept so nothing is lost.
  • Delete frees the space for good. You type DELETE to confirm.
Backups list with Restore and Delete
Backups: a size cleanup and an orphan move, each with Restore and Delete.
Typed DELETE confirmation before deleting a backup
Deleting for good needs DELETE typed first.

When to delete a backup

Browse your site for a few days after a cleanup. When every page looks right, delete the backup to get the space back.

What is never removed

  • The uploaded file of every media item.
  • The full-size original WordPress keeps for scaled images (-scaled).
  • Image editor backups.
  • With the default options, any file linked in your content.
  • Anything outside the uploads folder.

Your data

  • The plugin stores the sizes and options you picked, the state of the current run and the last scan result in a few options. It adds no database tables.
  • It adds nothing to the front end, sends no data anywhere and loads no external files.
  • Deleting the plugin removes its options. Backups stay on disk because they hold your files: delete them under Backups first, or remove the folder yourself.

Troubleshooting

ProblemWhat to do
Start cleanup stays greyed outRun a scan with the current sizes and options. Changing a switch after the scan needs a new scan.
An image looks wrong after a cleanupClick Restore on that cleanup under Backups, then turn the size back on and scan again.
A run stopped halfwayOpen the screen again and start a new scan. What was moved so far is in the backup and can be restored.
Some images were not rebuiltThe image editor could not read them. Their old size files are kept. Check that GD or Imagick is installed.
A file I need is listed as an orphanLeave Keep files linked in your content on, or restore it from the orphan backup after the move.
Images on a CDN or cloud storage did not changeThe plugin works on the files in your uploads folder. Remote copies are not changed.

Changelog

  • 1.2.0 (November 9, 2026): New screen under Media > Size Cleanup with Overview, Image sizes, Orphan files and Backups. The cleanup turns on only after a matching scan, the page remembers your sizes and options, deleting for good needs DELETE typed, and a run can be stopped. A failed rebuild keeps the image's size files, and a restore that can not put every file back keeps the backup. Now licensed under the GPL, version 2 or later.
  • 1.1.0 (October 27, 2026): Orphan files: find files in the year and month upload folders that no media item uses, and move them to a backup.
  • 1.0.2 (October 27, 2026): Rebuild missing sizes only. A size the rebuild can not create keeps its old file, and only the browser tab that started a run can drive it.
  • 1.0.0 (October 26, 2026): First release: pick the sizes to keep, rebuild with current settings, leftover files, scan with CSV, backup and restore.

Backups made with earlier versions are listed under Backups in 1.2.0 and can still be restored.

Need help?

Questions about setup or a feature request? Contact us on our support page. You can also download the latest version (v1.2.0) here.