As your WordPress website grows, you may end up accumulating hundreds, if not thousands, of images. While hosts aren’t usually stingy when it comes to storage space, it still makes sense to clean up your website. If you don’t, you might find yourself with a massive collection of unused media files that can slow things down.
Fortunately, WordPress makes it easy to both upload and delete media files. That means there’s no excuse not to tidy up your image collection from time to time. Once you do, you should see your site running more smoothly and your workflows improved.
In this article, we’ll discuss why you may want to clean up your WordPress Media Library. We’ll then show you how to prepare for that process, two ways to do it, and some maintenance tips for when you’re finished. Let’s dive in!
Why you should clean up your WordPress Media Library
In your personal life, you may have plenty of good reasons to keep files you don’t access on a daily basis. For example, you might need to hold on to official documents or important receipts. But it can be more difficult to justify a large reserve of media files on your website.
Most hosting plans have a limit on storage, so even if you have a generous amount of space, you’re bound to run out if you’re not careful. And when it comes to websites, media files usually take up the bulk of your quota. This is especially true if you use high-resolution and non-optimized images, which take up a lot of room.
Consider how many images you use on average for pages or blog posts. Even on a modest website, it’s not uncommon to have hundreds of media files.
As you update landing pages, refresh blog posts, or add new products, old media files may no longer be needed. But if you don’t remove them from the library, they still sit there — taking up space and making it all the more difficult to find the right files. You don’t want to sift through dozens of pages of files to find that one photo you need right away. Like a tidy workspace, a well-organized media library is worth the effort for the time and frustration it might save you every single day.
On occasion, having too many images on your server can also slow down your WordPress website. However, that’s usually only the case if you’re loading a page with a massive number of files and can easily be avoided by using a Content Delivery Network (CDN).
More importantly, if your Media Library is packed, this can be carried over to your backups, especially if they’re not incremental. This can cause site migrations and restorations — in addition to backups — to take much longer than necessary.
What to do before you delete media files in WordPress
Before you start deleting files from your Media Library, we recommend that you back up your website in its entirety. That way, if you delete any files that you can’t re-upload from your computer, you can revert to that backup.
There are a lot of ways to back up WordPress. Depending on your web host, you might have access to automated backups that you can restore from your hosting control panel. But in most cases, your best bet is to use a WordPress backup plugin like Jetpack Backup.
With Jetpack Backup, every change you make to your site is saved to the cloud in real time. That means you won’t need to create manual backups before updating your site, and you’ll always have recent copies available if something goes wrong.
Alternatively, if you’re planning to delete a large number of media files from WordPress, you might want to use a staging site. When you’re confident that you didn’t delete any critical media files, you can push that site live.
How to clean up your WordPress Media Library
Cleaning up media files in WordPress is remarkably simple. There are two ways you can go about this process: through the WordPress dashboard and via File Transfer Protocol (FTP).
1. Clean up media files in your WordPress dashboard
To get started, log in to your WordPress dashboard and go to Media → Library. When you do, the WordPress Media Library will open and you’ll be able to navigate through all of the images and videos you’ve uploaded to your site.
Deleting any single file within the Media Library is simple. Just click on the image or video that you want to remove and a window will pop up. The window will include a preview of the media file, relevant information, and its metadata.
If you look at the bottom right corner of this screen, you’ll see an option labeled Delete permanently. Click on it and confirm your decision.
Although this process is simple, it can be very time-consuming if you need to delete a large number of media files. If that’s the case, you can return to the main screen of the Media Library and look for the Bulk Select button in the menu near the top of the page.
Click on Bulk Select, and choose the files you want to remove. When you’re ready, select the Delete permanently option at the top of the screen.
WordPress will ask you to confirm the decision. After you do, the files will be gone. If you have multiple pages of media files, you’ll need to complete this process page by page.
2. Delete unused WordPress media files via FTP
Just as you can upload files to your media library via FTP, you can also use an FTP client to delete large numbers of media files at once. The advantage of this approach is that it can remove entire years or months of media files in a matter of seconds.
To get started, you’ll need to connect to your website via FTP. If you don’t have an FTP client, we recommend using one that enables you to preview media files, like SmartFTP or Cyberduck.
Most web hosts will provide you with a set of FTP credentials when you sign up for a plan. If you don’t have access to those credentials, you should be able to create a new FTP account through your hosting control panel.
Once you connect to your server, you’ll need to find the WordPress ‘root folder.’ It contains all of the files and subdirectories that make up your website. Usually, it’s called something like public_html, public, www, or your website’s name.
When you locate the root folder, go ahead and open it. You’ll see a file structure that looks something like this:
Next, find your WordPress media files in the wp-content/uploads directory. Inside, you’ll see folders for every year that your website has been around. Each year will contain subdirectories for individual months.
If you know what media files you want to delete by name, you can select them in bulk, right-click anywhere within the client, and then choose the Delete option.
This is where an FTP client that shows previews for media files may come in handy (like ForkLift or Commander One). With this option, it will be easier to determine which files to delete, even when you can’t identify them by name.
What to do after you clean up your WordPress Media Library
After you delete all of the unused media files in your library, there are a few things we recommend you do to complete the cleanup process. Fortunately, with the right tools, they’re very straightforward tasks.
1. Disable attachment pages in WordPress
By default, WordPress creates a new page for every media file you upload to your website. They’re called ‘attachment pages’ (or attachment posts), and in most cases there’s no reason to use them.
What’s more, if one of your images becomes popular (a lot of people are clicking on it), search engines might link to the attachment page directly. So you can end up getting clicks for a page that only includes an image or a video, and that doesn’t link to any other pages within your site.
After you remove unused images, you can end up with attachment pages that don’t have media files. That’s why we recommend disabling attachment pages entirely. This will also help keep your Media Library in check moving forward.
The easiest way to do this in WordPress is to use a Search Engine Optimization (SEO) plugin. You likely already have one installed, but if not, Yoast SEO and All In One SEO both include this feature.
If you’re using Yoast, go to SEO → Search Appearance → Media and look for the Media & attachment URLs option. Under ‘Redirect attachment URLs to the attachment itself?’ select Yes, and Yoast will disable attachment pages for media files.
Alternatively, if you’re using All In One SEO, go to All in One SEO → Search Appearance, and select the Image SEO option from the drop-down menu at the top of the screen. On the next page, beside the Redirect Attachment URLs setting, select Attachment Parent.
This option will automatically redirect users who land on attachment pages to the posts where those images can be found. If the images don’t exist anymore, the pages themselves won’t show up.
2. Check for missing images on your website
Unfortunately, when you’re cleaning up your WordPress library, you may accidentally delete some files that you didn’t intend to. You might not even notice until you’re browsing the website, and you run across a page that isn’t loading images you know should be there.
To avoid this, after you clean up your Media Library, we recommend that you check all of the main pages on your site to see if they’re missing any important images. If they are, you’ll need to re-upload those files or restore a recent site backup.
The easiest way to check large numbers of pages for missing images is to use a plugin like Broken Link Checker. This plugin can scan your site for broken links and images, so you don’t have to do so manually.
Once you install and activate this plugin, simply go to Settings → Link Checker and proceed to the Which Links to Check tab. Here, you’ll find multiple options for links and media files that the plugin can check.
If you just want to make sure you’re not missing any images, select the HTML images option and then click on Save Changes.
Go to the General plugin settings tab and you’ll find an overview of any missing images the plugin was able to locate. If you see a message that says No broken links found, that means you’re not missing any images.
Now you can go back to working on updating and improving your site. In most cases, you won’t need to clean your Media Library again for at least a few months.
3. Optimize your remaining images
Images are usually some of the largest files on a WordPress site and, because there are so many, can really slow things down. This is a big deal because users hate slow sites and search engines do, too.
Optimizing your images can go a long way without sacrificing quality. And this has the added benefit of taking up fewer server resources, which is particularly helpful on shared hosting plans.
The easiest way to do this is by using a WordPress image CDN like Jetpack. This tool automatically compresses images for fast delivery and even delivers the right file formats and sizes based on the device type a visitor is using. And all of this is done behind the scenes, without any work required on your end.
Remove unused images to keep WordPress running smoothly
If you’ve been running your website for a while, you probably have dozens of media files you’re not using anymore. That’s why occasionally cleaning up your WordPress Media Library is a wise idea. Removing unused images and files will free up storage and make your backups smaller and more manageable.
You can remove files directly from your Media Library in WordPress, or use an FTP client to delete them in large batches. Regardless of which approach you take, you’ll want to make sure to back up your site before deleting any files, and ensure that you haven’t thrown out anything essential when you’re done.
If you don’t have a backup solution in place, you’ll definitely want to check out Jetpack Backup. It saves your site in real-time, so you’ll have every single detail in case of emergency. Plus, it keeps an activity log so you can select the exact point in time to which you want to restore.
All of this is stored off-site on WordPress’ secure servers. So it won’t slow down your site and you can rest easy knowing your files are in good hands.
Explore the benefits of Jetpack
Learn how Jetpack can help you protect, speed up, and grow your WordPress site.
Try it for $1.00 for the first month.Compare plans