Clean up the WordPress Media Library or offload images to S3-compatible storage

Shrink the WordPress Media Library, Reduce the uploads folder, or offload images to S3-compatible storage to reduce storage space.

How to clean up and shrink the WordPress Media Library or uploads directory and save storage space. Reduce the WordPress Uploads folder using plugins or offload the uploads or Media Library to S3-compatible storage like DigitalOcean Spaces CDN.

Large uploads folder or unused or duplicate images

Some clients have a large uploads folder or media library, due to duplicate images or removed products from WooCommerce but the related images are not removed and using storage. While some WordPress installations are only 5 GB or 30 GB, I also have clients with an uploads folder larger than 200 GB.

I have used different techniques to reduce and repair WordPress installation size and databases, by cleaning them up manually and also rebuilding websites.

Use an Image Optimization plugin

I recommend a free Plugin that will resize images upon upload and convert and serve WebP images. There are different free and paid plugins, I like the free EWWW Image Optimizer plugin.

EWWW Image Optimizer (free)
EWWW Image Optimizer (paid plans)

The free plugin is good enough for most use cases and does what it must do and is very lightweight, and easy to set up.

Cleanup unused images

You can manually delete unattached images in the media library, but that is a lot of work and unreliable as some images marked as unattached are still used.

There are some plugins and techniques to clean up unused images, but they are not always reliable.

Make sure you have a backup at all times and test on a staging server/website.

Use a plugin free or paid to help find and remove unused or duplicate images

Use or choose a plugin that best suits your needs and remember.

Offload images using DigitalOcean Spaces

We can offload images using S3-compatible storage like DigitalOcean Spaces CDN. There are some popular plugins to offload images or the “uploads” folder to S3-compatible storage.

Some plugins that can help offload images:

Offload images using Google Cloud storage

You can also use a free plugin called WP Stateless, it is free and I have tested it personally back in 2018 when it was fairly new and under development. Currently, they have 5000+ active installations and are maintained and updated regularly.

It does what it is to do and I have not encountered any issues it has been working flawlessly for years, I tested synching images to Google Cloud Storage and back to the Media Library of WordPress.

Here is an article on Kinsta:

Do not confuse Google Cloud storage with CDN

Google Cloud Storage is a storage bucket in a region for example in London (Europe-west2), images will be served from the location you used to create the storage bucket.

Google storage price calculator

Use a CDN service and Google Storage as the origin

You can use a CDN service like KeyCDN, Bunny CDN or any other third-party CDN provider to pull data from Google Storage as its origin. Use a CDN to improve performance and page loading, this will serve images from a data center closest to the visitor of your website.

See this article on how to configure that:

Use Google Cloud CDN and Google Storage Bucket as origin

You can also use Google Cloud CDN and keep all services withing Google Cloud Platform. You will need a load balancer to configure Google Content Delivery Network to use with the WP Stateless Plugin and use a sub domain like

WP Stateless domain settings

Here is tutorial about: Set up a classic Application Load Balancer with Cloud Storage buckets

I used this tutorial to get started with creating a load balancer with Google Cloud CDN enabled. I only created 1 bucket which I use to offload media and I choose the HTTPS2 / HTTPS3 option and not the HTTP as in the tutorial. I also used a Google generated SSL certificate and pointed a DNS A record to the external IP address of the load balancer.

You will be billed for an external IP address, Load balancer and for Google CDN Cache Egress starting at $ 0.08 per GiB (<= 10 GiB).

Related articles and tutorials about offloading images


To reduce storage in the WordPress media library and shrink the “uploads” folder we can use image optimization plugins and plugins to help find and delete unused or duplicate images.

Some clients reported that using a free media cleaner plugin did not solve their problems or do a good job, and ended up with missing images.

Offloading images to DigitalOcean Spaces or S3-compatible storage is safe and will not result in missing images. You can choose to delete all images from the “uploads” directory after offloading images. This option is good for saving on storage with your hosting plan or server.

Sometimes if the uploads directory is extremely large it will be cheaper to offload images than using an instance with a large storage (storage optimized) or Volumes that you can not automatically backup. The automated daily server backup will back up the server but not the attached volume (storage) which you can backup by making a manual snapshot.

As with any plugin that can perform destructive operations on your database or files, using any of the mentioned plugins can result in permanent data loss if you’re not careful.

Leave a Comment