WordPress Media Library Clean Up – WPQuickeis

In this lunchtime #WPQuickies, I’ll walk through some strategies to help clean up the WordPress Media Library.

Too Much Stuff

It’s easy for your WordPress Media Library to become full of unused files, which can slow down your website and make media management difficult. 

By cleaning it up regularly and optimizing your images appropriately, you can be sure your website (and media content) is operating at its best.

Why Clean Up Your WordPress Media Library?

By default, when you upload a file to the media library, WordPress makes another three copies; a thumbnail, a medium and a large size.

Other themes and plugins may also add to this copy list for different sizes of images.

Before you know it, your media library is littered with multiple copies and sizes of the same image, some you may not even be aware of or need to use.

This will add to your overall disk space and if you have a small web host plan – that could be the reason you need to upgrade to a higher plan.

Also, the more files you have on your WordPress website, the bigger your backup files become and hence the longer they take to backup and restore.

You could start running into bandwidth issues on your web hosting account if the FTP transfers are included in that limit.

Resize Images

The best way to save space on your WordPress website is to resize your images.

I haven’t come across a client website that didn’t have 10-20Mb image files at crazy resolutions like 5000px wide, whilst only used as a blog post thumbnail.

Know the sizes of images you need for your website theme and resize those large images down to the correct size, while deleting the larger ones.

Not only will this reduce your web server and backups file sizes, but it’ll also help increase the speed of your website and that should reflect better SEO.

You can use a plugin called Imsanity to reduce the size of your large files.

I find that running plugins like this on the server slows down your website performance so I usually zip up the whole wp-content/uploads folder and download that to my local machine.

I can run batch resize and compression software to rescale and reduce file sizes.

After that’s done on local I zip and upload to the webserver, then unzip.

You will need FTP or control panel File Manager access to do this.

Use JPG Instead Of PNG Or Better Still WebP

The PNG file format is a lossless format meaning that there is no compression and each pixel is represented by a file byte.  

This means that PNG files can be large in size.

The only real reason you should be using PNG files on your website is if you need images with transparent backgrounds, otherwise stick to JPGs.

The JPG file format offers a range of compression options, most of them are indistinguishable to the human eye and are perfect for web pages.

You can go that extra one step and only use WebP images on your website.

WordPress 5.8 allows you to natively add WebP images.

The WebP images format had better compression than JPG and it supports transparency.

I always rescale and compress images on my local machine, however, if you can’t do that, then I would recommend you use the Shortpixel Image Optimiser plugin.

It will convert 100 images per month for free or you can buy credits relatively cheaply if you want to convert everything in one go.

Get Rid Of Extra Image Sizes

If you don’t need the default image sizes for medium and large, you can disable them in the WordPress media settings.

Navigate to Settings > Media

Entering 0 into the max width and max height fields will stop WordPress from creating those file copies.

Wordpress settings media

Remember to save the settings.

Deleting Unused Media Files

Now that your media library files are in the right size and format going forward, we need to remove those unused files.

This can be kind of tricky to do automatically.

Depending on the way you use images, WordPress doesn’t always keep an association between the file and a WordPress post.

If you’re new to WordPress, there are a couple of ways you can delete images and files from the media library.

Delete Single File

The first method is to open a single file and click on the “Delete permanently” link.

wordpress media library delete single media item

Deleting Multiple Files (Bulk Deletion)

You can delete multiple files from the media library by click on the “Bulk select” button.

wordpress media library delete multiple files

Then select the images you want to delete, WordPress will put a checkmark in the top right corner.

wordpress media library delete multiple files

When you have selected all the files to be deleted, click on the “Delete permanently” button.

This is a permanent deletion, so make sure you have a backup at hand should you mistakenly delete needed images.

Plugins To Delete Media Files

Manual deletion is the best option to limit the risk that needed images are removed.

However, if the task seems too time-consuming for you, here are some plugins that may help automate the process.

Remember that there are risks associated with using automated deletion plugins – have your backups handy just in case.

WP-Optimize

The WP-Optmize plugin https://wordpress.org/plugins/wp-optimize/ is one of my favourite optimisation tools for WordPress.

It has many other tools to optimise your WordPress website, however, for this case you can try to use the orphaned image search and deletion tool.

The plugin will attempt to locate media library images that aren’t associated with any post and delete them, or highlight them for you to save or delete.

WPS Cleaner

The WPS Cleaner plugin https://wordpress.org/plugins/wps-cleaner/ has a lot of website-wide optimisations.

It includes very good media library-related cleanup functions, where you can see the size of files including the total size of all media files.

The plugin tries to identify unused media files, allowing you to bulk delete them or individually.

Media Cleaner

The plugin Media Cleaner https://wordpress.org/plugins/media-cleaner/ only does one job and that is to try and identify unused media files.

Once installed, this tool will add all files not being used on your website (such as in posts, pages, or galleries) to a temporary trash bin. 

You can then review the files and choose which ones you want to permanently remove.

Organising WordPress Media File Assets

During the original WPQuickies stream was asked several times about file management within the WordPress media library.

The WordPress media library hasn’t fundamentally changed since I started using WordPress around 2008.

I personally would like to see a lot more focus on developing a better file asset management system to replace the ancient one there.

We’re currently stuck with a year and month default or bundle everything into a single folder.

Searching for file assets within the media library can only be done on filenames as there’re no other ways to categorise files.

There are a lot of different plugins that add organisation features to the media library, however, I like the simplicity of HappyFiles. https://happyfiles.io/

It allows files to be categorised.

happyfiles media library plugin

The free version of this plugin has currently been pulled from the WordPress.org repository due to what the plugin team call a violation of terms.

The free version of the plugin limits the number of categories to 10, however, the plugin team have determined that this constitutes trialware which is in breach of the guidelines.

However, there’s no mention of a trial or expiry in the free version, just a limit, the same way that Automattic’s own Jetpack plugin has limited features until you upgrade to the pro version.

You can download the free and pro version of HappyFiles from the developer’s own website.

How do you clean up your WordPress Media Library? Comment below.

#WPQuickies

Join me every Thursday at 1 pm Sydney time for some more WPQuickies – WordPress tips and tricks in thirty minutes or less.

Broadcasting live on YouTube and Facebook.

Suggest a #WPQuickies Topic

If you have a WordPress topic you’d like to see explained in 30 mins or under, fill out the form below.

https://forms.gle/mMWCNd3L2cyDFBA57

Watch Previous WPQuickies

WordPress On Amazon Web Services - WPQuickies

Pros & Cons of WordPress on AWS

Was this article helpful?
YesNo

Leave a Comment

Your email address will not be published. Required fields are marked *

Keep In Touch With My Weekly Blog Email

A once-per-week daily digest of my posts from the week. No sales, no spam and I will not share your details with anyone else.

Wil

Wil is a dad, WordPress consultant, WordPress developer, business coach and mentor. He co-organizes the WordPress Sydney meetup group and has been on the organising committee for WordCamp Sydney since 2014. He speaks at many special events and contributes to the WordPress open source project. His likes are chillies, craft beer and electrogravitics.

Leave a Comment

Your email address will not be published. Required fields are marked *