When running a WordPress site for months or years, your media library can get cluttered with images, PDFs, videos, and other files that are no longer used anywhere on your website. These are called orphaned media files files that exist in your uploads folder but aren’t linked to any post, page, or product.
Over time, orphaned media can bloat your hosting space, slow down backups, increase storage costs, and create unnecessary clutter in your file system. In this article, we’ll walk you through how to safely find and remove orphaned media files from your WordPress site without plugins or advanced developer tools.
What Are Orphaned Media Files?
Orphaned media files are those that:
-
Are uploaded to the
wp-content/uploads/
directory -
Exist in the Media Library or filesystem
-
But are not attached to any post, page, WooCommerce product, or custom post type
They can accumulate for various reasons:
-
You deleted posts/pages but not their media
-
You switched themes and unused images remained
-
You used a page builder that broke links to old files
-
Manual uploads via FTP or File Manager never got linked
Why Cleaning Orphaned Files Matters
Here’s why you should care about removing them:
-
Reduces clutter in your Media Library and folders
-
Frees up disk space, especially on shared or limited hosting
-
Speeds up backups by reducing the total file count
-
Improves security fewer old files = fewer vectors for attack
-
Improves site management by helping you stay organized
Step-by-Step Guide to Cleaning Orphaned Media Files
Step 1: Take a Full Backup
Before deleting anything, always create a full backup of your site files and database. You can use your hosting control panel, or a manual backup using:
-
File Manager or FTP: Download
wp-content/uploads
-
phpMyAdmin: Export your WordPress database
Even a single wrongly deleted file can break your layout, so backup is non-negotiable.
Step 2: Understand How WordPress Stores Media
Every media file uploaded through the WordPress dashboard gets:
-
Stored in
/wp-content/uploads/YYYY/MM/
-
Indexed in the
wp_posts
table withpost_type = 'attachment'
-
Linked via
post_parent
(to the post/page where it was used)
Orphaned files either:
-
Exist in the uploads folder but are not present in the database
-
Exist in the Media Library but are not attached to any content
Step 3: Find Unused Media Using the Media Library
Go to Media > Library > List View
-
Use the “Unattached” filter to find files not linked to any post or page.
-
You can review and delete these manually by clicking “Delete Permanently.”
This only detects files that were uploaded through the WordPress interface. It won’t detect files that are uploaded via FTP, or files used through custom code.
Step 4: Use File Manager to Find Unlinked Files
You can also explore the uploads/
directory using:
-
cPanel → File Manager →
public_html/wp-content/uploads
-
FTP/SFTP (FileZilla or similar)
Compare files in the uploads folder with the Media Library. Some advanced file managers (like MonstaFTP or Pydio) even support visual browsing and previews.
If you find any files in the folder that:
-
Are not listed in Media Library
-
Are not used in theme files
-
Are not included via custom shortcodes
You can move them temporarily to a folder like /uploads/_unused
before deletion.
Step 5: Search Your Database for Media Usage
For safety, you can search the WordPress database for file usage.
-
Open phpMyAdmin from your hosting control panel
-
Select your WordPress database
-
Use the Search tab to look for a file name (e.g.,
my-old-image.jpg
) -
Look in tables like:
-
wp_posts
-
wp_postmeta
-
wp_options
-
If the file is not referenced anywhere, it is likely orphaned.
Step 6: Manual Cleanup with Precaution
Once you’re sure a file is not used:
-
Delete it via File Manager or FTP
-
Or move it to a temporary archive folder (
/uploads/orphans-backup/
) before final deletion
This way, you can restore it quickly if something breaks.
Bonus Tip: Automate the Process (Safely)
If you manage a large WordPress site and need to clean up hundreds of files, some WordPress plugins (like Media Cleaner or WP-Optimize) offer advanced scanning features.
However, use them with extreme caution:
-
Always test on a staging site
-
Always take backups before running bulk actions
-
Review every file marked for deletion
Final Thoughts: Keep Your Media Library Lean
A bloated media folder is a silent performance killer. Keeping your WordPress uploads organized isn’t just about tidiness it helps save server resources, simplifies maintenance, and ensures your backups are lightweight.
To prevent orphaned media from piling up again:
-
Delete media when deleting posts/pages
-
Avoid uploading files unless you’re sure you’ll use them
-
Regularly audit your Media Library
By taking a few simple precautions and cleaning up regularly, you’ll ensure your site stays fast, efficient, and easier to manage.