Privacy

Clean up the WordPress Media Library without deleting images you still use

Unattached does not mean unused. Reconcile attachment records with real references, preserve originals and generated sizes, and prove a small cleanup can be reversed.

Made by Pagember · Editorial policy

Editorial guidancePublished Updated Sources

The short answer

Do not bulk-delete items labeled Unattached, since images used in templates, backgrounds or emails may still be needed. Review a small group of candidates individually, check where each file is referenced, and make a restorable files-and-database backup tested on a private staging copy. Deleting from the Media Library is permanent by default unless media trash is enabled in wp-config.php.

On this page9 sections

Do not delete every item labeled Unattached. In WordPress, an attachment's relationship to a parent post is different from every place its image or file is used. A logo in a template, a background image or an old PDF linked from an email may remain useful even when the library does not associate it with an article.

Complete official WordPress W mark above a conceptual live-page image linked to a reviewed library item, with a reminder that unattached does not mean unused.

To see the candidates, go to Media → Library, switch to the list view with the icon at the top left, and choose Unattached in the filter dropdown. The Uploaded to column then shows "(Unattached)" for each item. Deleting from this screen is permanent by default: WordPress has no media trash unless define( 'MEDIA_TRASH', true ); is added to wp-config.php.

A safe cleanup is a dependency review with a tested recovery path. Begin with a small group of candidates, identify what would be removed and prove that you can restore the required records and files. A scanner's “unused” label is a lead to investigate, not authorization for a bulk deletion.

Separate the cleanup goals

Write down the problem first. Perhaps uploads are approaching a hosting allowance, editors cannot distinguish approved artwork from abandoned drafts, or the same photograph has been uploaded several times. Those goals require different changes. Better names and an asset register can improve editorial organization without removing any file.

For storage reduction, record the relevant allowance and a current measurement from the responsible system. Do not assume that the library's item count describes total disk usage. One record can have several generated images, while other storage may sit outside the Media Library. If the goal is page performance, start with our image-sizing workflow; deleting unrelated old uploads does not establish that a current page downloads less.

Understand what Unattached actually tells you

The Media Library documentation describes managing attachment items and their relationships. The important limitation is that this administrative view is not a complete map of all references. Removing or changing a parent association does not remove a file URL already stored elsewhere.

The core get_attached_media() reference makes the distinction concrete: attached-media retrieval uses a post-parent relationship. It is not an exhaustive search through every published page, template, custom field or external document.

For example, an unattached venue map may be linked from the contact page and printed workshop material. It also has a photograph associated with a deleted draft but reused in a pattern. Both need a usage review. Neither should be removed solely because its original upload context is no longer active.

Make an inventory before choosing candidates

For each candidate, record its attachment ID, title, complete file address, upload date, dimensions or file type, original source and any known purpose. Keep related generated files together rather than treating each thumbnail as an independent disposable upload.

WordPress attachment metadata can identify dimensions and recorded sizes. Use it to understand the asset family, while remembering that it is not a usage log. Plugins, offloaded storage and custom rendering can add dependencies that a core-only inventory misses.

Hypothetical candidateEvidence foundInitial decision
Venue map PDFContact page and printed notice link to its addressRetain and document its owner
Old banner photographUsed in a reusable pattern outside the original draftRetain until that pattern is replaced
Abandoned test imageNo reference in the reviewed scope; original preservedCandidate for a limited staging test
Similar-looking logoDifferent crop; actual destination references not checkedKeep pending review

Use that last category deliberately. Unknown does not mean unused. A short unresolved list is more useful than a clean-looking library produced by deleting items nobody took responsibility for checking.

Look beyond article bodies

Search the supported content and configuration surfaces that your site actually uses. Include published and draft posts, featured images, reusable patterns, navigation, template parts, custom fields and relevant plugin settings. Background images may appear in styles rather than ordinary image blocks.

Check both attachment-ID references and file addresses. A copied image URL can remain in a paragraph, stylesheet or download button even if no attachment relationship points to it. Review original and derivative addresses where the implementation uses them. Searching only for a filename stem can also confuse two different uploads.

Then identify uses outside the website's editable content: newsletters, PDFs, partner pages and printed QR destinations. You may not be able to enumerate every external reference. Preserve a resource when an ongoing outside use is known, or replace it through a planned stable route instead of assuming a local crawler can see the whole dependency.

Treat cleanup tools as scoped evidence

One widely used free tool is Media Cleaner. It checks the Media Library against the places content references media, flags unused and broken entries, and moves deletions to its own trash first. Its page lists which builders the free version can read; support for Elementor, ACF and several other builders is part of the Pro version. If using it or another inventory tool, read what it examines and which integrations it supports. Does it inspect rendered pages, stored post content, featured-image metadata, builder fields and theme settings? Record its exclusions with the scan date.

Review a few known-used examples first. If a tool labels the active header logo unused, stop and resolve that blind spot before trusting a long deletion list. Do not compensate by disabling the theme or removing references simply to make a report agree with your desired result.

Keep detection separate from deletion. Export or save the candidate list, review exceptions and use the smallest practical test group. Avoid direct database or filesystem purges that bypass the site's supported media management and leave relationships unexplained.

Prove recovery before testing removal

Preserve a backup that includes the required database records and uploaded files, with access to any external storage involved. BlogVault backs up both off the server, and its selective restore can return individual files without rolling back newer posts. Keep source originals independently where appropriate. Our restorable WordPress backup guide explains why the presence of an archive is weaker evidence than a successful recovery check.

Use a private staging copy with the relevant theme, plugins and content. Protect it from public access and unintended transactions; see the staging privacy checklist. Test a representative restore there and verify that an attachment's identity, file routes and appearances remain consistent.

An ordinary content export should not automatically be treated as a complete media recovery set. Our WordPress export and import guide distinguishes records and media transfer. A newly uploaded copy may have a new ID or address, leaving an old reference unresolved.

Do not assume deletion has an Undo button

The attachment deletion reference distinguishes trash behavior from permanent deletion under the applicable configuration and operation. Plan as though a removal needs your independent recovery route unless the exact installation's behavior has been established.

Remove only the reviewed test group through supported controls. Record the exact IDs, related file paths, time and responsible person. Deletion does not rewrite every old link into a useful replacement. If a file should move, update the relevant content and plan its old route before removing it.

Verify the journeys that depended on the candidates

  • Open representative published pages, listings and templates on desktop and phone widths.
  • Inspect featured images, background images, downloads and reusable content.
  • Check a fresh logged-out view and the relevant cached delivery path.
  • Compare the actual storage measurement with the original goal.
  • Restore one removed test item and verify its original references work again.

If anything breaks, stop the cleanup and restore the affected asset family and records using the established recovery plan. Do not blindly restore an old production database over newer orders, messages or editorial work. Resolve the narrow dependency, document the missed reference and improve the inventory before another group is considered.

A successful small test supports that reviewed scope. It does not prove that every remaining unattached file is safe to remove. Retain the evidence and repeat the review when a redesign or plugin change alters how the website stores media references.