The size of your WordPress media library will increase over time, taking up disk space and slowing down your website. That's why it is recommended to regularly clean up your WordPress media library.
In this guide we show you how to clean up unused media files manually or with a plugin and give you tips on how to avoid a large media library.
- What is the WordPress media library?
- Why clean up the WordPress media library?
- How to delete unused files manually
- Use a plugin to clean up the media library
- How to avoid a large media library
Note: This action cannot be undone. Before you continue we recommend that you make a backup of your site. Check out our guides below if you are unsure how to do this.
What is the WordPress media library?
The WordPress Media Library is a catalogue of all the media files that you have uploaded to your website, such as images, audio and video files and documents. You can find the media library in your WordPress dashboard.
- Log into your WordPress admin dashboard.
- Click Media in the menu on the left and select Library.
Why clean up the WordPress media library?
The size of your WordPress media library will increase over time because unused images are not automatically deleted. WordPress also duplicates uploaded images into different sizes by default.
A large media library takes up unnecessary disk space, increases backup sizes, complicates media management and negatively affects the performance and speed of your website. If your website has been up and running for some time, chances are high that the media library contains images that are not actually used by your website.
How to delete unused files manually
If your media library isn't very large and has a manageable file count, you can remove unused files manually. You can either remove a single image at a time or bulk-remove multiple images in one go.
- In the WordPress dashboard, click on Media in the menu on the left and select Library.
- Select the image you want to delete.
- In the pop-up window showing the attachment details, choose Delete Permanently in the bottom-right corner.
- Click OK to confirm that you want to permanently delete the file.
Tip: You can also bulk-delete files and images. Simply click the button Bulk Select in the Media Library, choose all files you would like to delete, and click on "Delete Selected".
Use a plugin to clean up the media library
If you have a large media library, it can be time-consuming to clean it up manually. Luckily, there are plugins that can help you.
We recommend using the plugin Media Cleaner to clean up your media library. Media Cleaner is a free plugin, that will scan your WordPress media library and look for files that are broken or aren't actually used by your website.
Once the scan is done it will present you with an overview of the files that it has flagged during the scan. You can then review the files and select which files you want to remove. You can also click on the "Delete All" button to remove all unwanted media files in one go.
Note: Any media files removed by the plugin will be permanently deleted, it is therefore strongly recommended that you make a backup of your files and database before you proceed.
How to avoid a large media library
There are some preventive actions you can take to keep the media library from growing too big. We have collected some tips for you.
Optimise your images
The primary goal of optimising your images is to find the balance between the lowest file size and an acceptable quality. There are many benefits of optimising your images, such as making your website load faster, improved SEO rankings, using less disk space and faster website backups.
Compress images before uploading
Image compression is an important factor when it comes to optimising images.
You can compress your images before you upload them to the media library in an image editing tool such as Adobe Photoshop or GIMP. There are also tools online that you can make use of.
Upload smaller images
Another important factor when it comes to image optimisation is image scaling.
Images directly uploaded from smartphones or cameras are usually high-quality images that are huge in file size and not optimised for the web. Usually, these huge images are not shown in their original size on the website but are instead downsized with HTML or CSS, yet the visitor's browser still downloads the full-size image in its original size.
Instead, we recommend that you upload smaller images to the media library so that it matches the actual pixel dimensions you use to display it on your website, which means a reduction in file size.
It is recommended to regularly check and clean up your WordPress media library to keep it from accumulating in size. We recommend you do this on a monthly basis, but the more often you do it the better.
Use JPG format rather than PNG
Two of the most common file image formats are JPG and PNG. JPG files are better for photography while PNG is preferred when it comes to graphs, images with text or that require the use of a transparent background, such as logos for instance.
PNG files are often higher in quality but that also makes them bigger in file size. We recommend using JPG files for images on your website because images that are big in size will make your website load slower and impact the visitor experience negatively.