0

Pretty much as the title suggests

I have items on my server (images mostly) that do not feature anywhere in the media library. What is the best way to delete these?

Is there a plugin or would I need to create a list of files, dump them into a table and do a search/compare against media tables to see if the files exist, and if not, to delete them?

Thanks

1

Just because something is not in the media library it doesn't mean that it is not used in your site or by some other site. The problem that you may run into is deleting a file that it is actually used.

On the other hand, just because a file is "located" in the media library doesn't mean it is actually used.

Therefor a better question should be "How to identify media files which are not used" for which unfortunately I have no answer and would be off-topic on the wordpress development site. I just don't delete files. It is a waste of space but unless you use services like S3 in which you pay for each byte of storage the risk of going into the trouble of locating the file in the backup just not worth the small saving you get from deleting the files.

0

Mark Kaplan's modification to the question is correct. Media files can be either 'attached' to posts and needed by the site or can be referenced in a page link thus becoming an 'unattached' media files needed by the site. I have no plugin or programming solution but have used the following solution steps. 1. Scan the site with Screaming Frog SEO spider (or equivalent) and extract the csv file of all internal URLs. Filter that list to only have the URLs that point to /upload folder. These are the 'used' media files. 2. Copy the titles of all media files in the /upload folder. 3. Remove all of items in item 1 from item 2. What remains is the list of unused media files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.