WordPress – Delete All Unattached Images from Media Library

Sometimes we have hundreds of unnecessary images in our WordPress media library. For example, many of our files have not been attached to any post, and have remained in our library without fulfilling any function beyond occupying space and overloading our server.

Therefore, we want to show you how to remove all unattached images from your media library, so that your server is no longer overloaded and takes up valuable space. It’s very fast and simple. And it doesn’t matter if there are thousands of files you have to delete; this plugin applies the changes in batches so that the server is not overloaded while you are applying the changes. You won’t get error 500 or anything like that.

Just follow these simple steps.

1- Install the Media Library Spreadsheet plugin

The Media Library Spreadsheet plugin displays all your media files on a spreadsheet so that you can apply changes to them quickly. It contains a powerful Bulk Edit tool to help you do that. Also, you can filter your products and make advanced searches. You won’t have to spend hours editing your files.

You can download the plugin here:

Download Media Library Spreadsheet Plugin - or - Check the features

2- Open the Media Library Spreadsheet

Once you install and activate the plugin, please go to Sheet Editor > Edit Media, and you’ll see the spreadsheet with all your media library files and their complete information.

wordpress-delete-all-unattached-images-from-media-library

3- Attach images

You need to click on Attach Images, and then click on Start to make sure the values in the “Attached to this post” column are correct.

4- Open the “Bulk Edit” tool

To delete all the unattached files from your media library, you need to use the Bulk Edit tool. It helps you apply thousands of changes to thousands of products in seconds. It’s located on the plugin’s toolbar, so just click on it to open.

wordpress-delete-all-unattached-images-from-media-library

5- Find all the unattached images

To find all the unattached images, you need to first select the I want to search rows to update option in the Select the rows that you want to update field. This will open an advanced search tool.

wordpress-delete-all-unattached-images-from-media-library

Now, just tick the Enable advanced filters checkbox and use these values.

wordpress-delete-all-unattached-images-from-media-library

  • Field key: Format
  • Operator: CONTAINS
  • Value: image

Click on Add new and use these values in the new filter.

  • Field key: Attached to this post
  • Operator: =
  • Value: 0

Finally, click on Run search. This will filter all your unattached images and take you back to the bulk edit fields.

6- Delete all unattached images

Once back in the bulk edit fields, you need to select these values to delete all the filtered images.

wordpress-delete-all-unattached-images-from-media-library

  • Select the rows that you want to update: I want to select rows to update
  • What field do you want to edit: Status
  • Select type of edit: Set value
  • Replace existing value with this value: Delete completely
  • Click on Execute now

Done!

You no longer have to spend hundreds of hours checking on every image in your media library and deleting them one by one. The Media Library Spreadsheet has come to simplify your media library management completely.

You can download the plugin here:

Download Media Library Spreadsheet Plugin - or - Check the features

Do you need help?

You can receive instant help in the live chat during business hours, or you can contact us and we will help you via email.