The Blog

Recovering disk space in WordPress by deleting unused media

Nearly all website hosting packages impose a maximum disk space capacity. This capacity can usually be increased by upgrading the hosting package, for an additional cost.

If operating a WordPress powered website, as time passes, the website content will build up gradually, as new pages and blog posts are added; this causes extra disk space to be consumed. The rate of consumption is higher where new media (images and PDFs) are frequently added.

Note that any updates involving just text usually have a comparatively negligible impact on disk space; it’s images and PDFs which use up space.

The WordPress Media Library

It’s wise to review media, delete any unused media permanently and free up disk space.

Here’s the problem: the Media Library in WordPress will display all the media – but won’t identify media not being used in the website (e.g. displayed on a page, post, as part of the page design – or in a gallery, etc.).

There is an option to only show “unattached” media but, without resorting to a long and hefty explanation about this, unfortunately it won’t usually be of much help.

Manually deleting

Having deleted redundant pages and posts from your website (maybe noting down media you longer require), you can manually go through the Media Library and using the bulk action option, delete multiple images or PDFs.

Bulk media deletion in WordPress

Subsequently, if you use a Link Checker plug-in (as all our websites do), it will soon indicate any missing media on pages and posts.

With a prior back-up of the WordPress “Uploads” folder (you may need to ask your web designer to do this), the missing images can be fairly easily transferred back into position on the server if deleted by mistake.

Using a plug-in

There are several plug-ins available which offer the possibility of an automatic solution – but many appear to be provide unreliable results, have been abandoned by the original developers and are plainly risky. Of those which we’ve investigated there are currently two plug-ins which deserve consideration:

Both of these plug-ins look very promising but we haven’t carried out enough tests to be sure of their reliability or to recommend them. So tread carefully (and definitely back up beforehand). We still think that in many cases, for various technical reasons, many of your unused images may still not be identified by these plug-ins.

The sad truth is that there’ll never be a ‘magic bullet’ to remove all unused media instantly and reliably.

Jordy Meow (developer of ‘Media cleaner’) sums the situation up very nicely when asked whether his plug-in is safe:

“No! 🙂 How can a plugin that deletes files be 100% safe? 😉 I did my best (and will improve it in every way I can) but it is impossible to cover all the cases. On a normal WordPress install it should work perfectly, however other themes and plugins can do whatever they want do and register files in their own way, not always going through the API. I ran it on a few big websites and it performed very well. Make a backup (database + uploads directory) then run it. Again, I insist: BACKUP, BACKUP, BACKUP! Don’t come here to complain that it deleted your files, because, yes, it deletes files. The plugin tries its best to help you and it is the only plugin that does it well.”

Scroll Up