Linux 软件免费装
Banner图

CPW Media Offload for Cloudflare R2

开发者 criandoparaweb
更新时间 2026年10月21日 22:12
PHP版本: 7.4 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

cdn webp cloudflare r2 media offload

下载

1.4.0 1.3.0 1.3.1 1.2.1 1.4.1 1.3.2 1.4.2 1.5.0 1.5.2

详情介绍:

CPW Media Offload for Cloudflare R2 copies your WordPress Media Library to a Cloudflare R2 bucket and rewrites the media URLs of your site so visitors download images, videos and documents from Cloudflare instead of your web server. The Cloudflare R2 free tier includes 10 GB of storage and, when the bucket is served through a custom domain, no egress fees. That makes it a practical way to keep a small hosting plan fast: your server stops sending megabytes of images on every page view and stops filling its disk with thumbnails. What it does WebP and AVIF without loading your server Image conversion normally costs CPU: the server decodes the upload and re-encodes it, which is slow on shared hosting and simply unavailable where PHP was built without WebP support. This plugin can hand that work to Cloudflare instead. Turn on Convert on delivery and your media URLs are served through Cloudflare Image Transformations, which converts each image to AVIF or WebP according to what the visitor's browser accepts, resizes it to the width actually needed, and caches the result on the edge. This requires a custom domain connected to your bucket, because transformations are served by the Cloudflare zone that answers for that domain. The r2.dev development address cannot do it. The Cloudflare free plan includes 5,000 unique transformations per month; repeat visitors are served from the cache and cost nothing. Page builder and theme compatibility Media URLs stored inside page builder data are rewritten as well, so background images, galleries and sliders keep working after an offload: Elementor's CSS cache is cleared automatically after an offload so its generated files point at the new URLs. Page cache plugins When media URLs change, because an existing library is offloaded, a file is copied back to the server or sent again, or delivery from R2 is switched on or off, the page cache is cleared so visitors never get pages that still point at the old addresses. Supported: WP Rocket, LiteSpeed Cache, W3 Total Cache, WP Super Cache, WP Fastest Cache, SiteGround Speed Optimizer, Cache Enabler, Comet Cache, Breeze, Hummingbird, WP-Optimize, Swift Performance, Autoptimize, Nginx Helper, Kinsta, WP Engine and Pantheon. During a bulk run the cache is cleared once, a couple of minutes after the changes stop, and new uploads never clear it. Languages The plugin is fully internationalised. Translations are provided through translate.wordpress.org, where Brazilian Portuguese and any other language can be contributed. Security

安装:

  1. Install and activate the plugin.
  2. In your Cloudflare dashboard create an R2 bucket and an R2 API token with Object Read and Write permission.
  3. Go to Media → Cloudflare R2 and fill in the account id, access key id, secret access key and bucket name.
  4. Click Test connection.
  5. Give the bucket a public URL: either enable the r2.dev development URL, or, recommended for production, connect a custom domain to the bucket in Cloudflare. Paste that address in Public bucket URL.
  6. Open the Offload tools tab and run Start offloading to move the existing library.
  7. Back in Settings, enable Serve media from R2.
  8. Only after checking that your site renders correctly, enable Delete the local copy after a successful upload to free disk space.
  9. Optional, and only if step 5 used a custom domain: enable transformations for that zone in Images → Transformations in your Cloudflare dashboard, then turn on Convert on delivery so Cloudflare serves WebP and AVIF without your server encoding anything.

屏幕截图:

  • Connection settings, with step by step help for finding each value in your Cloudflare dashboard.
  • Delivery from Cloudflare and image optimisation: WebP and AVIF made by Cloudflare on the way out.
  • Offloading rules: new uploads, local copies, deletions, WebP conversion and file limits.
  • Offload tools: move the existing library, copy it back to the server or rebuild the index from the bucket.
  • Activity log, so upload problems are visible without server access.

升级注意事项:

1.4.2 Shows the CPW R2 Pro add-on on the plugin screen. Nothing changes in how your media is offloaded or served. 1.4.1 Prepares the settings screen for connections managed by a Multisite network. Nothing changes in how your media is offloaded or served. 1.4.0 Security fix for stores: files for sale stop going to the public bucket. New dashboard, setup wizard and settings layout, plus extension points for add-ons. Nothing changes in how your media is offloaded or served. 1.3.2 Cosmetic release: makes the support panel easier to find. Nothing changes in how your media is offloaded or served. 1.3.1 Cosmetic release: adds a support panel to the plugin screen. Nothing changes in how your media is offloaded or served. 1.3.0 Adds WebP and AVIF conversion done by Cloudflare on delivery, so no image is encoded on your server and your originals stay untouched. Needs a custom domain connected to your bucket. 1.2.1 Housekeeping release for the WordPress.org directory. No functional change. 1.2.0 Renamed to CPW Media Offload for Cloudflare R2. Settings and offloaded files are preserved; the plugin folder changes, so deactivate the old copy after installing this one. 1.1.1 Adds step-by-step help on the settings screen for finding each credential in the Cloudflare dashboard. 1.1.0 Deleting the plugin no longer wipes your settings and offload index. Adds WebP conversion on upload, a re-send action and a tool to rebuild the index from the bucket. 1.0.1 Maintenance release: internationalisation and database query fixes, plus WordPress 7.1 compatibility. 1.0.0 First public release.

常见问题:

Do I need a paid Cloudflare plan?

No. The R2 free tier includes 10 GB of storage per month plus a monthly allowance of read and write operations, which is enough for most small and medium sites. The plugin shows how much of that allowance your media uses.

Is there a Pro version?

Yes, as a separate add-on. Everything this plugin does is free and will stay free. CPW R2 Pro adds what stores, agencies and larger sites need: private files with signed URLs for WooCommerce and Easy Digital Downloads, background offload with WP-CLI, Multisite and theme and plugin assets served from R2.

Does it work with Elementor?

Yes. Beyond the standard WordPress media functions, the plugin rewrites the URLs stored inside Elementor documents, so widgets, galleries and background images all point at Cloudflare. The Elementor editor keeps working with local paths, and Elementor's CSS cache is cleared after an offload.

Will my media break if I deactivate the plugin?

No, as long as the local copies still exist: URLs simply go back to your server. If you enabled local deletion, run Copy everything back to the server in the Offload tools tab before deactivating.

Can I keep using the WordPress image editor?

Yes. Since version 1.5.0 it also works with local deletion enabled: when you open an image in the editor, crop it in the Customizer or pick it as the site icon, the plugin copies it back to the server first. Once you save, the edited image is offloaded again and, with local deletion on, removed from the server.

Does it delete my files from R2 when I uninstall the plugin?

Never. Uninstalling removes only the plugin settings, log and internal post meta. Your bucket is left untouched.

I deleted the plugin and lost the record of what was offloaded. What now?

Your files are still on the bucket: the plugin never deletes them. Go to the Offload tools tab and run Rebuild the index, which checks every attachment against the bucket and restores the record without uploading anything. To stop it happening again, keep the setting Keep the settings and the offload index enabled, which is the default from version 1.1.0. Note that deleting a plugin runs its clean up routine, while updating one does not.

Does the plugin convert my images to WebP?

If you turn it on, and there are two ways to do it. Convert on delivery hands the work to Cloudflare, which is the recommended option and is covered in its own question below. Convert to WebP under Offloading does it on your own server instead: JPEG and PNG uploads are converted before the thumbnails are generated, so every size is WebP and the smaller file is what counts against your storage. GIFs are never converted so animations survive, and an image is only replaced when the WebP version really is smaller. It applies to new uploads: images already in the library are left as they are.

Can Cloudflare convert my images instead of my server?

Yes, and it is the better option. Turn on Convert on delivery under Image optimisation on Cloudflare. Your images are then served through Cloudflare Image Transformations, which converts them to AVIF or WebP per browser and caches the result. Your server never decodes or encodes an image, the originals on the bucket stay as they are, and images already in your library are covered without any reprocessing. You need a custom domain connected to your bucket and transformations enabled for that zone in Images → Transformations in the Cloudflare dashboard. The r2.dev development address does not go through a zone and cannot transform anything; the settings screen tells you when that is the case.

What does the Cloudflare conversion cost?

The Cloudflare free plan includes 5,000 unique transformations per month. A unique transformation is one combination of options applied to one image: the first visitor pays for it and everyone after that is served from the cache, at no cost. Beyond the free allowance Cloudflare charges per thousand. The plugin uses a short ladder of five widths by default to keep that count low, and the cpw_r2_transform_widths filter lets you shorten it further.

Should I use the upload conversion or the delivery conversion?

Use one or the other, not both. The delivery conversion is the better default: it costs your server nothing, keeps your originals intact and applies to your whole library at once. The upload conversion is for sites without a custom domain on Cloudflare, or for anyone who would rather store the smaller file on the bucket and accept losing the original.

Can several sites share one bucket?

Yes. Give each site a different Path prefix, for example site-a and site-b.

I replaced a file but visitors still see the old one. Why?

Since version 1.5.0 this is handled for you. Every time a file is sent to the bucket again, its URL gets a new ver value, so browsers and the Cloudflare cache fetch the new content instead of the copy they kept for a year. Files offloaded only once keep their plain URL.

Do deleted files keep being served by Cloudflare?

On a custom domain, yes, until their cache expires: deleting an object from the bucket does not touch the copy Cloudflare keeps on the edge. To clear it automatically, fill in Zone ID and API token under Delivery > Cloudflare cache purge. The token needs the Zone > Cache Purge permission only. The plugin then clears the cached copy whenever a file is deleted from the bucket or sent again, and Test cache purge checks the values without purging anything. If Cloudflare times out, limits the requests or has an outage, the files are queued and tried again automatically, waiting longer each time, for about half an hour; a refused token is reported in the Log tab instead of retried. Both values can also be defined in wp-config.php as CPW_R2_CF_ZONE_ID and CPW_R2_CF_API_TOKEN.

Some images have no thumbnails on the bucket. How do I fix them?

Versions before 1.5.0 offloaded an upload before WordPress had created its thumbnails, so only the main file reached the bucket and, with local deletion on, no thumbnail was ever made. Run Send everything again once in the Offload tools tab. It brings back the files whose local copy was deleted, creates the missing thumbnails and sends every size to the bucket.

What happens to files that fail to upload?

They are flagged and skipped so the bulk tool can continue. The reason is recorded in the Log tab, and Queue failed files again puts them back in line.

更新日志:

1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.2 1.3.1 1.3.0 1.2.1 1.2.0 1.1.1 1.1.0 1.0.1 1.0.0