S
WS R2 Storage
v1.0.0WordPressWP 7.1PHP 7.4+GPL-2.0-or-later
Stores the WordPress media library in Cloudflare R2. New uploads go to the bucket with every image size and are served from the bucket's public URL. The existing library can be moved to the bucket or pulled back, and files already in the bucket can be imported into the media library. No bundled SDK and no Composer dependencies: the AWS Signature V4 client is built in.
Download v1.0.0
Features
- New uploads are copied to the bucket with every generated size. The local copies can be kept or deleted.
- URLs are rewritten everywhere WordPress builds them: attachment URL, image
src and srcset, the media modal and the REST API. Post content is not rewritten, so old local files and new offloaded files live side by side.
- Later changes are synced too: regenerated thumbnails, image editor results, new image sizes added by a theme, and the
-scaled original WordPress makes for large images.
- Migrate Files: move the existing library to the bucket, or bring it back, in batches with pause and resume.
- Import from R2: list the bucket and create attachments for the objects you select; thumbnails are generated and uploaded next to the original.
- Deleting an attachment deletes its objects. A folder prefix per site lets several sites share one bucket.
- The secret key is encrypted at rest (libsodium, OpenSSL fallback) or supplied as a constant in
wp-config.php.
How it works
The plugin hooks the attachment metadata: each time WordPress generates or updates it, the files it names (original, scaled original, every size) are compared with the list already uploaded for that attachment, and the missing ones are sent to the bucket. The first upload is all-or-nothing, so a failed upload leaves the attachment local. Each attachment remembers the prefix it was stored under, so changing the prefix later does not break older files. Object keys mirror the uploads folder: <prefix>/2026/10/photo.jpg.
Requirements
- WordPress 5.9+, single site
- PHP 7.4+
- Tested up to WordPress 7.1
- An R2 bucket with a public URL (custom domain or
r2.dev) and an API token with object read and write permissions
Install
- Download the zip above.
- In WordPress go to Plugins, Add New, Upload Plugin, and upload it.
- Activate WS R2 Storage from the Plugins screen.
- Settings, R2 Storage: enter the Account ID, the Access Key ID, the Secret Access Key, the bucket, the folder prefix and the public URL. Save, then use Test Connection.
- Upload as usual. Use the Migrate Files tab to move the existing library.
Updates are self-hosted: the plugin reads its Update URI header and checks https://websqu.ad/updates/ws-r2-storage.json. New versions show up in the standard WordPress updates screen.
Good to know
- With Delete Local Files on, regenerating thumbnails or editing an image has no original to work from. Run Migrate Cloud to Local first, then Migrate Local to Cloud again.
- Post content keeps the URL that was current when it was written. Changing the public URL later needs a search-replace.
- One upload request holds the whole file in memory; files larger than 40% of the PHP memory limit stay local and are reported in the PHP error log.
- WebP or AVIF copies made by plugins outside the attachment metadata are not synced.
- Rotating the site's security keys makes the stored secret unreadable; the settings page says so and the key must be entered again, or set as
WS_R2_STORAGE_SECRET_KEY.
Changelog
- 1.0.0 — first release under the websquad convention, after a full code review of the earlier in-house version. The AWS SDK is replaced by a built-in client; files changed after the first upload (regenerated thumbnails, image editor results, scaled originals) are now synced; import validates every object key and never overwrites a local file; migrations report a failed attachment once instead of retrying forever; the secret key is encrypted at rest; settings are validated; self-hosted updates.
websquad — brandsquad OÜ, Estonia. Support: [email protected]
WP Plugins · Homepage