Skip to content
GPLWP Guides

How to remove unused media from WordPress

Media & Galleries Time About 20–45 minutes 6 steps Updated 8 Sep 2026

MEDIA & GALLERIES
The short answer

WordPress does not reliably identify every unused file by itself. For a small library, review unattached media and delete confirmed items from Media > Library; for a large or builder-heavy site, use a scanner, review its results, then delete in bulk after a backup.

The route
  1. 01Back up before deleting
  2. 02Filter likely candidates
  3. 03Check where each file is used
  4. 04Delete confirmed files
  5. 05Check the site after cleanup
  6. 06Use a scanner for large libraries

What you need

  • Administrator access to WordPress
  • A recent full site backup
  • A staging site for large or business-critical websites
  • A list of page builders, ecommerce plugins, or custom fields in use

Back up before deleting

Create a full database and file backup before removing anything. Keep the backup until you have checked important pages, templates, products, galleries, and downloads.

Do not start by deleting files directly from wp-content/uploads. WordPress stores media as attachment records as well as files, and deleting only the files can leave broken records and links.

Filter likely candidates

Go to Media > Library and switch to List view. Use the media-type and date filters, then review items marked as unattached. WordPress provides an Unattached filter and bulk deletion tools, but an unattached item is not automatically unused: it may be referenced by a page builder, theme setting, custom field, product, or direct URL.

For a small library, this manual route is usually enough. Work in batches rather than selecting every old or unattached item at once.

Check where each file is used

Open each candidate and inspect its URL, filename, title, and preview. Search the site for the filename or URL, and check posts, pages, reusable blocks, menus, widgets, theme options, WooCommerce products, page-builder templates, CSS, and downloadable files.

Pay particular attention to images used as featured images or background images. Removing an image from one post does not normally remove it from the Media Library, and the same attachment may be used in several places.

Delete confirmed files

In the Media Library, select only files you have confirmed are not needed. Choose Delete Permanently for immediate removal, or move items to Trash first if your site supports media trash. WordPress's attachment deletion process removes the attachment data and, on permanent deletion, the associated file and generated sizes.

Do not delete an item merely because it is old, unattached, or has a duplicate-looking filename. If the file is used by a live page, that page can show a missing image or download link after deletion.

Check the site after cleanup

Visit the homepage, key landing pages, galleries, blog posts, product pages, forms, downloads, and builder templates. Check both desktop and mobile layouts, then clear any page, object, CDN, or browser caches.

If something is missing, restore the item from Trash or restore the backup. A backup is useful only if you know where it is and have confirmed that it can be restored.

Use a scanner for large libraries

The fast way is to use Media Cleaner Pro. Back up the site, run its media scan, review the reported orphaned or unused items, and delete only the results you recognise as safe. Its bulk deletion and backup options make it better suited to a large library than checking hundreds of files by hand.

Treat scan results as a shortlist, not proof. Review items used in Elementor or other builders, WooCommerce products, theme settings, custom fields, and hard-coded URLs before confirming deletion.

The fast route

Let Media Cleaner Pro do it

Scans for orphaned files and supports bulk deletion with backups; choose it for thorough media-library cleanup.

Get Media Cleaner Pro

Sources

  1. wordpress.org /documentation/article/media-library-screen/?utm_source=open…
  2. wordpress.org /support/topic/when-delete-images-it-deletes-from-all-posts-…
  3. developer.wordpress.org /reference/functions/wp_delete_attachment/?utm_source=openai

Questions

Are unattached media files unused?
No. An unattached media file is not linked to a post or page through WordPress's normal attachment relationship, but it can still be used in a page builder, theme option, custom field, product, CSS rule, or direct URL. Use the Unattached filter to find candidates, then verify each file before deletion.
What happens when I delete media from WordPress?
Deleting media removes its attachment record, and permanent deletion also removes the associated file and generated image sizes. Any page, product, gallery, template, or download still pointing to that file can break. Move uncertain items to Trash first when possible, and keep a restorable backup until the site has been checked.
Can I delete unused files from the uploads folder?
You should not delete uploads directly as your normal cleanup method. The file may still have an attachment record, or another part of the site may reference its URL. Delete confirmed media through the WordPress Media Library or a tool that uses WordPress's attachment deletion process, then check the front end.
What is the safest way to clean a large WordPress media library?
The safest approach is to make a full backup, scan the library, review the reported candidates, delete in small batches, and check important pages after each batch. A scanner can find likely orphaned files faster than manual filtering, but builder content, custom fields, and hard-coded URLs still need human review.