Getting Started

Introduction

A {{ cfimage }} Statamic tag, shaped to feel like {{ glide }}, that serves and transforms images through a Cloudflare Worker (R2 binding + Workers Images binding) instead of Glide/GD on the app server. No image processing or image bytes ever pass through your Statamic site.

Why not Glide?

Glide (and Laravel's own Image facade) both do the resize/encode work on your own server, on request. This addon moves that entirely to Cloudflare's edge: the Worker reads the source straight out of R2 and transforms it there, so origin CPU and bandwidth are never in the path for image variants after the first request.

Architecture assumptions

This addon is built around two things being true of your infrastructure:

  • Your zone (domain) is on Cloudflare — the Worker is deployed as a route on that zone, so Cloudflare has to be managing DNS for it.

  • Your asset originals live in Cloudflare R2 — the Worker reads the source file directly out of R2 itself. Assets stored elsewhere (S3, local/public disk, another CDN) aren't supported today.

How the pieces fit together

If you haven't used Cloudflare before, three separate things need to exist before {{ cfimage }} will serve anything:

  1. R2 — Cloudflare's object storage. Your asset files themselves (originals) need to actually live here. This addon doesn't upload anything for you — you point a normal Laravel filesystem disk at R2 and Statamic uploads to it exactly as it would to local disk or S3.

  2. A Worker — a small script Cloudflare runs at the edge, published by this package into your app under workers/cfimage/. It receives the signed URLs this addon builds, reads the source file out of R2, resizes it via the Workers Images binding, and returns the result.

  3. This package — builds signed {{ cfimage }} URLs pointing at your Worker, and gives you php artisan cfimage:publish to keep the Worker's own config (wrangler.toml, preset table) in sync with config/cfimage.php so nothing is maintained in two places.

Next

Prerequisites