TP Media Offload & Edge CDN
TP Media Offload & Edge CDN
Description
TP Media Offload & Edge CDN is a powerful WordPress plugin that offloads your media files to Cloudflare R2 object storage and serves them through Cloudflare’s global CDN network with automatic image optimization.
Key Features
- R2 Storage Integration – Seamlessly upload media to Cloudflare R2 with S3-compatible API
- Automatic Offload – New uploads are automatically offloaded to R2
- Bulk Offload – Offload existing media library with configurable batch size
- CDN Delivery – Serve media through Cloudflare’s global CDN network
- Image Optimization – Automatic WebP/AVIF conversion via Cloudflare Image Transformations
- Responsive Images – Smart srcset generation with preset breakpoints (320, 640, 768, 1024, 1280, 1536)
- Quality Control – Configurable image quality (1-100)
- Worker Auto-Deploy – One-click Cloudflare Worker deployment for image processing
- WooCommerce Support – Full integration with product images and galleries
- Background Processing – Queue-based processing with WP Cron (Action Scheduler supported)
- Media Library Integration – Status column, bulk actions, and row actions
- WP-CLI Support – Command line interface for bulk operations and automation
Requirements
- WordPress 6.0 or higher
- PHP 8.0 or higher
- Cloudflare account with R2 storage enabled
- R2 bucket with public access or custom domain
- Cloudflare API Token (for Worker deployment)
How It Works
- Configure your R2 credentials (Account ID, Access Key, Secret Key, Bucket)
- Set up your CDN URL (R2 public domain or custom domain)
- Enable auto-offload or use bulk offload for existing media
- Plugin automatically rewrites URLs to serve from CDN
- Cloudflare Worker handles image transformations on-the-fly
Security
- API credentials encrypted with AES-256-CBC + HMAC
- Rate limiting on settings saves
- Nonce verification on all AJAX requests
- Capability checks for all admin operations
- Secure uninstall (wipes all sensitive data)
Performance
- Batch processing to prevent memory exhaustion
- Transient caching for dashboard stats
- Conditional asset loading
- Background queue processing
Build and Generated Assets
This plugin includes compiled frontend assets in:
assets/js/admin.jsandassets/js/public.jsassets/css/admin.cssandassets/css/public.css
Source files are included in the same plugin package:
- JavaScript source:
assets/src/js/admin.js,assets/src/js/public.js - SCSS source:
assets/src/scss/admin.scss,assets/src/scss/public.scss
Build steps used to generate compiled files:
npm installnpm run build
Development watch mode:
npm run dev
External services
This plugin connects to Cloudflare services to offload media and deliver files via CDN.
Cloudflare R2 Object Storage
- What it is used for: Store and serve media objects.
- Data sent: Account ID, Access Key ID, Secret Access Key, bucket name, file paths, and media file contents.
- When data is sent: During connection testing, single/bulk offload, restore, and local-file cleanup actions.
- Service provider: Cloudflare, Inc.
- Terms of Service: https://www.cloudflare.com/website-terms/
- Privacy Policy: https://www.cloudflare.com/privacypolicy/
Cloudflare API (Workers and DNS)
- What it is used for: Deploy/remove Workers, validate DNS records, and enable DNS proxy for CDN routing.
- Data sent: API token, account ID, zone ID, DNS record ID, worker configuration, and configured CDN domain.
- When data is sent: When you click Deploy Worker, Remove Worker, Validate DNS, or Enable Proxy.
- Service provider: Cloudflare, Inc.
- Terms of Service: https://www.cloudflare.com/website-terms/
- Privacy Policy: https://www.cloudflare.com/privacypolicy/
Privacy Policy
This plugin:
* Stores your Cloudflare API credentials encrypted in your WordPress database
* Uploads your media files to your Cloudflare R2 bucket
* Sends required API data directly to Cloudflare services to provide plugin functionality
* Does not include any tracking or analytics
Your data stays between your WordPress site and your Cloudflare account.
Support
For support, feature requests, or bug reports:
* Visit WordPress support forum
* Create an issue on GitHub (coming soon)
Credits
- Built with AWS SDK for PHP for R2 compatibility
- Uses WP Cron for background processing (Action Scheduler compatible)
- Cloudflare Workers for image transformations
Disclaimer
This plugin is an independent, third-party project and is not affiliated with, endorsed by, or officially associated with Cloudflare, Inc. in any way. “Cloudflare” and “R2” are trademarks of Cloudflare, Inc. The use of these names is solely for descriptive purposes to indicate compatibility with Cloudflare services.
This plugin is developed and maintained independently by the plugin author and the open-source community.
Installation
- Upload the plugin files to
/wp-content/plugins/tp-media-offload-edge-cdnor install through WordPress plugins screen - Activate the plugin through the ‘Plugins’ screen in WordPress
- Go to TP Media Offload & Edge CDN in the admin menu
Initial Setup
Step 1: Configure R2 Storage
- Log in to your Cloudflare dashboard
- Go to R2 > Overview and create a bucket
- Go to R2 > Manage R2 API Tokens
- Create a new API token with read/write access
- Copy Account ID, Access Key ID, and Secret Access Key
- Enter these in the plugin’s Storage tab
Step 2: Configure CDN (Optional but Recommended)
- In Cloudflare, set up a custom domain for your R2 bucket
- Or use the R2.dev public URL
- Enter the CDN URL in the plugin’s CDN tab
Step 3: Deploy Worker (For Image Optimization)
- Create a Cloudflare API Token with Workers permissions
- Enter the token in the CDN tab
- Click “Deploy Worker” button
- Worker will be automatically deployed
Step 4: Start Offloading
- Enable “Auto Offload” for new uploads
- Use “Bulk Actions” tab to offload existing media
- Monitor progress in the terminal-style activity log
WP-CLI Commands
The plugin provides WP-CLI commands for automation and bulk operations:
wp cfr2 status
Show offload statistics (total, offloaded, not offloaded, disk saveable, pending).
wp cfr2 offload <id|all> [--dry-run] [--batch-size=50]
Offload media to R2. Use specific ID or “all” for bulk offload.
wp cfr2 restore <id|all> [--dry-run] [--batch-size=50]
Restore media from R2 (removes R2 metadata, reverts to local URLs).
wp cfr2 free-space <id|all> [--dry-run] [--batch-size=50]
Delete local files for offloaded media to free disk space.
Examples:
# Check current offload status
wp cfr2 status
# Offload single attachment
wp cfr2 offload 123
# Offload all media with larger batch size
wp cfr2 offload all --batch-size=100
# Preview what would be offloaded (dry run)
wp cfr2 offload all --dry-run
# Free disk space by removing local copies
wp cfr2 free-space all
Faq
Cloudflare R2 is an S3-compatible object storage service with zero egress fees. It’s perfect for storing and serving media files.
No, R2 storage is available on all Cloudflare plans including Free. You get 10GB storage free per month. Pricing: $0.015/GB/month after that.
First 5,000 transformations per month are free. After that, it’s $0.50 per 1,000 transformations. The plugin tracks your usage in the dashboard.
Yes, there’s an option to keep local files. This is useful for backup or if you need local file access.
Media URLs will revert to local paths. Your files remain in R2 storage. The plugin stores original local URLs for seamless fallback.
Yes! Full WooCommerce integration for product images, galleries, and thumbnails.
Yes, use the “Restore” action in Media Library or bulk restore in the Bulk Actions tab.
The plugin supports WebP (recommended) and AVIF conversion. Original format is preserved as fallback.
Currently designed for single-site installations. Multisite support is planned for future releases.
Yes! The plugin includes WP-CLI commands for bulk operations: wp cfr2 status, wp cfr2 offload, wp cfr2 restore, and wp cfr2 free-space. All commands support --dry-run and --batch-size options.
Reviews
Changelog
1.0.2
- Follow-up release for 1.0.1 to correct packaged version metadata in WordPress.org SVN trunk and tag builds.
- Added stricter release verification so plugin header
Version,CFR2_VERSION,Stable tag, and generated SVN artifacts must match the requested release version before deployment. - Updated release documentation and changelog metadata for the 1.0.2 rollout.
1.0.1
- Fixed plugin activation to create the full R2/CDN settings schema instead of legacy placeholder settings.
- Added settings normalization and migration so existing installs automatically receive missing keys safely.
- Improved validation across settings save, Worker actions, WP-CLI, media actions, and queue processing with clearer configuration errors.
- Hardened queue scheduling fallback for sites without Action Scheduler and reduced duplicate queue items in bulk operations.
- Fixed Cloudflare zone detection for custom domains, corrected Worker route generation, and cleared CDN availability cache when CDN settings change.
- Updated uninstall/deactivation cleanup to handle current encrypted secrets correctly.
- Cleaned up PHPCS violations, repaired PHPMD and pre-commit tooling, refreshed bundled documentation, and added regression tests.
1.0.0
- Initial release
- R2 storage integration with AWS SDK
- Automatic and bulk media offload
- CDN URL rewriting
- Cloudflare Worker auto-deployment
- Image optimization (WebP/AVIF)
- Responsive srcset generation
- WooCommerce integration
- Background queue processing
- Rate limiting and security features
- Dashboard with usage statistics
- WP-CLI commands (status, offload, restore, free-space)