Server Administration

Offloading WordPress Media to S3, R2 or Other Object Storage

Offloading WordPress Media to S3, R2 or Other Object Storage

The uploads folder is the part of a WordPress site that grows without anyone noticing. Every image upload creates several resized copies. Every PDF, video and audio file goes in there too. After a few years, a typical business site’s wp-content/uploads might be five or ten gigabytes. A busy publication or WooCommerce store can easily reach a hundred. When you offload WordPress media to object storage, most of those problems disappear.

At that size, problems start appearing. Backups take hours and fill up storage. Migrations become a weekend project. Staging sites need their own copy of everything. Disks fill up on small servers. And scaling to more than one web server becomes awkward, because every server needs the same files.

Object storage solves most of these problems by moving media files off your web server and into a service designed to store huge numbers of files cheaply and reliably. This article explains how it works, when it’s worth doing and how to make the move without breaking images across your site.

What object storage is

Object storage services, like Amazon S3, Cloudflare R2, Backblaze B2, DigitalOcean Spaces and Wasabi, store files as “objects” in “buckets”. You don’t mount them like a normal disk. Instead, you upload and fetch files through an API, and each file gets a URL.

They’re designed for durability and scale. You don’t worry about disk size, RAID or backups of the storage hardware. You pay for what you store and, depending on the provider, for data transferred out.

That last point matters. Amazon S3 charges for egress, the data sent to visitors. Cloudflare R2 doesn’t charge for egress at all. For a media-heavy site, that difference can be significant.

How media offloading works in WordPress

WordPress doesn’t natively store uploads anywhere except the local filesystem. Offloading plugins add that capability. The general flow is:

  1. You upload a file through the media library as usual.
  2. WordPress saves it locally and generates the resized versions.
  3. The plugin copies the original and all sizes to the bucket.
  4. The plugin rewrites media URLs in your content so they point to the bucket or a CDN in front of it.
  5. Optionally, the plugin deletes the local copies to save disk space.

Popular plugins include WP Offload Media, Media Cloud and several smaller alternatives. They differ in which providers they support, how they handle existing media and whether they rewrite URLs on the fly or store new URLs in the database.

When offloading makes sense

Offloading adds a moving part, so it’s not worth doing for every site. It makes sense when:

  • Your uploads folder is large, roughly 10 GB or more, and growing.
  • Backups are slow or expensive because of media.
  • You run multiple web servers behind a load balancer, or plan to.
  • Your hosting has limited disk space and expanding it is expensive.
  • You serve a lot of large files, such as downloads, podcasts or video, and want to reduce bandwidth on your server.

It’s usually not worth it when:

  • Your uploads are a few gigabytes and growing slowly.
  • You’re on managed WordPress hosting that already handles storage and CDN well.
  • Nobody on the team is comfortable managing cloud storage accounts and credentials.

Choosing a provider

For most WordPress sites, the choice comes down to cost and simplicity.

Cloudflare R2 has no egress fees and integrates neatly if you already use Cloudflare. You can attach a custom domain to a bucket, so media is served from something like media.example.com through Cloudflare’s network.

Amazon S3 is the most widely supported and has the richest feature set, but egress costs add up. It’s often paired with CloudFront as a CDN.

Backblaze B2 is inexpensive and offers free egress through Cloudflare via the Bandwidth Alliance.

DigitalOcean Spaces includes a built-in CDN and simple pricing, convenient if your server is already on DigitalOcean.

Whichever you choose, put a CDN in front of it and serve media from a custom subdomain. Don’t serve directly from a raw bucket URL. A custom domain means you can switch providers later without rewriting every URL again.

Setting up the bucket

The exact steps vary by provider, but the principles are the same.

  1. Create a bucket in a region close to your audience or your server.
  2. Create an access key with permission only for that bucket. Don’t use account-wide root credentials.
  3. Decide whether files should be publicly readable. For normal media, yes. For private downloads, no, and you’ll use signed URLs.
  4. Connect a custom domain or CDN.
  5. Configure CORS if you’ll load fonts or use media in JavaScript from the bucket.

Store the access keys in wp-config.php as constants rather than in the plugin’s settings screen, so they’re not stored in the database:

That example uses WP Offload Media’s constant. Other plugins have their own equivalents.

Migrating existing media

New uploads are easy. Existing media is where the planning matters.

Step 1: Back up everything

Take a full backup of files and database before you begin. URL rewriting touches a lot of content, and you want a clean way back.

Step 2: Copy files to the bucket

Most plugins have a tool to upload existing media in the background. For large libraries, it can be faster to sync the uploads folder directly with a command-line tool and then tell the plugin about it. Tools like rclone or the AWS CLI handle this well:

Keep the same folder structure so paths match.

Step 3: Update references

The plugin needs to know which attachments are in the bucket. Some plugins scan and record this. Others rewrite URLs on output, so they don’t need to change content in the database.

If URLs are stored in post content, which they are for images inserted in the editor, they either need to be rewritten in the database or filtered on output. Filtering is safer and reversible. Database rewriting is faster at runtime but harder to undo.

Step 4: Test before deleting local files

Don’t remove local files until you’ve confirmed everything works. Check:

  • Images in posts and pages, including old ones
  • Featured images and thumbnails in archive pages
  • Galleries and sliders
  • WooCommerce product images and gallery zoom
  • Images in CSS from page builders, which often store absolute URLs separately
  • Downloads and PDFs linked from content
  • Media in custom fields

Page builders are the most common source of missed images, because they store URLs in their own data formats.

Step 5: Remove local copies, optionally

Once you’re confident, you can enable the plugin’s option to remove local files after upload, or delete the old files manually. Keep a backup of the original uploads folder somewhere for a while.

Things that can go wrong

Image editing and regeneration. When WordPress regenerates thumbnails or you crop an image in the media library, it needs the original file. Plugins handle this by downloading from the bucket temporarily, but some regeneration tools don’t expect files to be remote.

Plugins that read files from disk. Image optimisation plugins, PDF generators and some backup tools expect local files. Check compatibility before you remove local copies.

Private files. Membership sites and digital download stores shouldn’t put protected files in a public bucket. Use a private bucket with signed, expiring URLs.

Costs creeping up. Request charges and egress fees can surprise you on providers that charge for them. Set up billing alerts.

Staging environments. Decide whether staging uses the same bucket, a copy or local files. Sharing a bucket risks staging deleting production media. A read-only setup or a separate bucket is safer.

Backups after offloading

Offloading doesn’t remove the need for media backups. Object storage is durable against hardware failure, but not against accidental deletion, a compromised access key or a plugin bug that removes files.

Enable versioning on the bucket if your provider supports it, so deleted or overwritten files can be recovered. Alternatively, run a periodic sync to a second bucket with a different provider. Your site backups can then exclude the uploads folder, which makes them much smaller and faster.

The payoff

Done well, offloading makes a large site much easier to run. Server disks stay small. Backups shrink from hours to minutes. Migrations become a matter of moving code and a database. Staging copies are quick to create. And adding web servers becomes straightforward, because media no longer lives on any of them.

It’s a change best made deliberately, with a backup, a test plan and a clear rollback route. Rushed, it can leave broken images scattered across hundreds of pages. Planned, it’s one of the most satisfying infrastructure improvements you can make to a growing WordPress site. If you decide to offload WordPress media, treat it as a small project with a plan, not a plugin you switch on one afternoon.

Frequently asked questions

Will offloading media make my site faster?

Mainly if you also serve media through a CDN. The speed benefit comes from the CDN. Offloading’s main benefits are storage, backups and scalability.

Can I go back to local storage later?

Yes, if you keep the folder structure consistent. Download files back to the uploads folder and deactivate the plugin or remove the URL rewriting.

Does it work with WooCommerce?

Yes. Product images work like any other media. Downloadable products need private storage with signed URLs, which most offload plugins support.

Is Cloudflare R2 really free for egress?

R2 doesn’t charge for data transferred out. You still pay for storage and for operations above the free allowance, so check current pricing for your usage.