=== Bandwidth Saver: Image CDN === Contributors: imgpro Tags: cdn, images, cloudflare, performance, bandwidth Requires at least: 6.2 Tested up to: 6.8 Requires PHP: 7.4 Stable tag: 0.1.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html Deliver images from Cloudflare's global network. Save bandwidth costs with free-tier friendly R2 storage and zero egress fees. == Description == **Image CDN** is a bandwidth-saving WordPress plugin that delivers your images through Cloudflare's global edge network. Unlike complex image optimization services, Image CDN focuses on one thing: making your existing WordPress images load faster worldwide while cutting bandwidth costs. **No transformations. No complexity. Just fast, affordable delivery.** = How It Works = 1. **WordPress generates images** (as it normally does) 2. **Image CDN rewrites URLs** to point to Cloudflare 3. **First request:** Worker caches image in R2 4. **Future requests:** Served directly from R2 (zero cost!) = Key Benefits = * **Free Tier Compatible** - Most sites pay $0/month * **One-Click Setup** - Start with ImgPro Cloud instantly * **Works with WordPress** - No fighting against WP image handling * **Works with ANY Plugin** - Use your favorite optimization plugins * **Global Edge Delivery** - Fast worldwide * **Zero Egress Fees** - Cloudflare R2 advantage = What It Does = * Serves images through Cloudflare CDN * Caches all WordPress image sizes * Automatic responsive images (srcset) * Smart fallback for cache misses * Works with featured images, content images, galleries = What It Doesn't Do = * Image transformations (use WordPress or plugins) * Dynamic resizing (use WordPress image sizes) * Quality optimization (use optimization plugins) * Format conversion (use WebP plugins) **Why:** WordPress already handles image optimization. Image CDN just makes delivery faster and cheaper. = Perfect For = * Blogs wanting faster image delivery * Sites on slow hosting * Global audiences * Free tier Cloudflare users * Developers who want simple solutions == Installation == = Quick Start (Recommended) = **ImgPro Cloud** - No Cloudflare account needed: 1. Install and activate the plugin 2. Go to Settings → Image CDN 3. Click "Use ImgPro Cloud" 4. Done! Your images now load from Cloudflare's global edge network Free while in beta. No credit card required. = Advanced Setup (Optional) = **Use Your Own Cloudflare Account** - Full control over infrastructure: **Requirements:** * Cloudflare account (free tier works) * R2 enabled in Cloudflare Dashboard * Domain on Cloudflare (for worker routes) **Setup:** 1. Deploy the Cloudflare Worker to your account (~15 minutes) See: https://github.com/img-pro/bandwidth-saver-worker 2. Configure R2 bucket with custom domain 3. Enter your domains in Settings → Image CDN For detailed instructions, see the worker repository documentation. == Frequently Asked Questions == = How much does this cost? = Most small/medium WordPress sites pay **$0/month** on Cloudflare's free tier. Cost breakdown: * Small (100k views/mo): $0/mo * Medium (500k views/mo): $0-2/mo * Large (3M views/mo): $0.68/mo = Do I need to configure image quality? = No! Image CDN serves the exact images WordPress generates. Use your favorite WordPress image optimization plugin to optimize images before they're cached. = Does it support WebP? = Image CDN serves whatever WordPress generates. If you use a WebP conversion plugin, Image CDN will cache and serve those WebP files. = Is this compatible with optimization plugins? = Yes! Image CDN works with ALL WordPress image optimization plugins. It doesn't matter which optimization plugin you use - Image CDN will cache and serve the optimized images. = What happens when I uninstall the plugin? = The plugin completely removes all settings and data upon uninstallation: * Plugin settings (imgpro_cdn_settings) * Version tracking (imgpro_cdn_version) * Works with multisite installations Your WordPress images remain unchanged in the media library. Images cached in Cloudflare R2 are not automatically deleted - you can manage those separately in your Cloudflare dashboard. = Does it work with page builders? = Yes! Works with all WordPress page builders including Gutenberg and popular third-party page builders. = Can I use my own Cloudflare account? = Yes! That's how it's designed. You deploy the worker to your own Cloudflare account and have full control. = What if I don't want to use Cloudflare? = This plugin is specifically designed for Cloudflare R2. If you need a different CDN, consider other plugins. == Screenshots == 1. Welcome screen - Choose between ImgPro Cloud (one-click setup) or self-hosted Cloudflare 2. Active state - Plugin enabled with ImgPro Cloud, images delivered globally 3. Settings interface - Configure CDN domains, allowed domains, and excluded paths == Changelog == = 0.1.0 (2025-11-10) = * NEW: ImgPro Cloud quick-start option with one-click setup * NEW: Empty state with two setup options (ImgPro Cloud vs self-hosted Cloudflare) * NEW: Cloud usage indicator when using ImgPro Cloud domains * NEW: Direct link to worker setup guide for self-hosting * UI: Complete admin interface redesign with modern design system * UI: Comprehensive accessibility improvements (ARIA labels, focus states, keyboard navigation) * UI: Typography system with consistent scale and spacing rhythm * UI: Micro-interactions and polished hover states throughout * UI: Mobile-responsive design optimized for all screen sizes * UI: Semantic HTML structure with proper heading hierarchy * UI: Visual grouping of settings with clear sections * UX: Simplified copy and reduced redundancy throughout interface * UX: Left-aligned empty state for cleaner appearance * UX: Streamlined settings card with reduced visual noise * Performance: Request-level caching reduces context detection overhead * Accessibility: Supports high contrast mode and reduced motion preferences * Code: External CSS replaces inline styles for better caching = 0.0.8 (2025-11-11) = * CRITICAL FIX: Fixed JavaScript string escaping breaking image display * Fixed onload/onerror handlers using incorrect quote style causing syntax errors * Fixed images remaining hidden due to imgpro-loaded class never being added * Fixed AJAX action name mismatch in admin toggle functionality * All inline JavaScript now properly escapes quotes for WordPress attribute handling = 0.0.7 (2025-11-09) = * Performance: Added request-level caching to context detection (99% reduction in redundant checks) * Performance: Moved inline CSS to external file for better browser caching * Performance: Optimized is_unsafe_context() with early termination * Code Quality: Enhanced method documentation with comprehensive DocBlocks * Code Quality: Extracted 800+ bytes of inline styles to external CSS file * Security: Added comprehensive error handling for parse_url() failures * Security: Graceful fallback to original URLs on malformed input * Impact: 10-15% performance improvement on image-heavy pages = 0.0.6 (2025-11-09) = * CRITICAL: Fixed Jetpack compatibility issue with lazy context evaluation * Fixed REST_REQUEST timing bug (constant not available at plugins_loaded) * Architecture: Always register hooks, check context when executed * Compatibility: Jetpack connection, backups, and Block Editor now work correctly = 0.0.5 (2025-11-02) = * Removed fade-in animation for instant image display * Simplified CSS (visibility toggle only) = 0.0.4 (2025-11-02) = * Added smooth image loading transitions * Prevents broken image icon flash * Created frontend CSS file = 0.0.3 (2025-11-02) = * Fixed rtrim() bug causing attribute corruption * Changed to surgical regex for self-closing marker removal = 0.0.2 (2025-11-02) = * Fixed regex pattern to avoid false matches on data-src attributes * Uses positive lookbehind for accurate matching = 0.0.1 (2025-11-02) = * Initial release * Cache-only architecture (no transformations) * Free-tier friendly Cloudflare R2 storage * Two-domain setup (CDN + Worker) * Automatic fallback on CDN failures * Compatible with all WordPress optimization plugins == Upgrade Notice == = 0.1.0 = Major update with ImgPro Cloud quick-start, completely redesigned admin interface, and comprehensive accessibility improvements. Recommended for all users. = 0.0.8 = CRITICAL UPDATE: Fixes JavaScript errors preventing images from displaying. Update immediately if experiencing blank/hidden images. = 0.0.7 = Performance improvements and security hardening. Recommended update for all users. == Technical Details == = Architecture = **Two-Domain Setup:** * `cdn.yourdomain.com` → R2 Public Bucket (99% of traffic, zero worker cost) * `worker.yourdomain.com` → Cloudflare Worker (1% of traffic, cache misses only) **Request Flow:** 1. Browser requests image from CDN domain 2. If cached: Served directly from R2 (20-40ms) 3. If not cached: Fallback to worker domain 4. Worker fetches from WordPress, stores in R2, redirects to CDN 5. Future requests: Served from R2 (zero worker invocations) = Performance = * **Cached requests:** 20-40ms (R2 direct) * **Cache miss:** 200-400ms (fetch + store + redirect) * **Cache hit rate:** 99%+ after warmup * **Worker invocations:** ~1% of total requests = Storage = Images are stored in R2 with path-based keys: ``` example.com/wp-content/uploads/2024/10/photo.jpg example.com/wp-content/uploads/2024/10/photo-300x200.jpg ``` No hash generation, no transformation parameters - just simple caching. = Code Statistics = * **Worker:** 1 file, ~150 lines * **Plugin:** 4 classes, ~1,900 lines * **Dependencies:** Cloudflare R2 only * **Complexity:** Very low = Open Source = * Full source code available * Fork and modify as needed * Deploy to your own Cloudflare account * No vendor lock-in * GPLv2 or later licensed = Documentation = * **Plugin Repository:** https://github.com/img-pro/bandwidth-saver * **Worker Repository:** https://github.com/img-pro/bandwidth-saver-worker == Support == For support: 1. **WordPress.org Support Forum:** https://wordpress.org/support/plugin/bandwidth-saver/ 2. **Plugin Documentation:** https://github.com/img-pro/bandwidth-saver 3. **Worker Documentation:** https://github.com/img-pro/bandwidth-saver-worker 4. **Cloudflare Dashboard:** Check worker metrics and logs == External Services == This plugin connects to Cloudflare's infrastructure to deliver images globally: **Cloudflare R2 (Object Storage)** * Service: https://www.cloudflare.com/developer-platform/products/r2/ * Purpose: Stores cached images for global delivery * Privacy Policy: https://www.cloudflare.com/privacypolicy/ * Terms of Service: https://www.cloudflare.com/terms/ * Required: You must create your own Cloudflare account and deploy the worker * Data: Only publicly accessible images from your WordPress site are cached **Cloudflare Workers (Edge Compute)** * Service: https://www.cloudflare.com/developer-platform/products/workers/ * Purpose: Processes new images and cache misses * You control: You deploy the worker code to your own Cloudflare account * No data sharing: Images flow directly from your WordPress site to your Cloudflare account **Important:** This plugin does not send any data to third parties. All images are cached in YOUR Cloudflare account under your control. The plugin author has no access to your images or data. == Privacy == This plugin: * Does not collect any user data * Does not use cookies * Does not track anything * Does not send data to plugin author or third parties * Only caches publicly accessible images in your Cloudflare R2 bucket * No analytics, no telemetry Your images are stored in your own Cloudflare account. Review Cloudflare's privacy policy for details on how they handle data. == Credits == Built for the WordPress community. Powered by: * Cloudflare R2 (object storage) * Cloudflare Workers (edge compute) * Cloudflare CDN (global delivery)