symfony / ux-cloudflare-image
Symfony UX Image Cloudflare Bridge
Package info
github.com/symfony/ux-cloudflare-image
Type:symfony-ux-image-bridge
pkg:composer/symfony/ux-cloudflare-image
Requires
- php: >=8.4
- symfony/ux-image: ^3.6
Requires (Dev)
- phpunit/phpunit: ^12.0
- spatie/phpunit-snapshot-assertions: ^5.2.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
EXPERIMENTAL This component is currently experimental and is likely to change, or even change drastically.
Cloudflare Image Resizing integration for Symfony UX Image, through the /cdn-cgi/image/ URL path. Use this bridge to transform images already served from your own origin ("bring your own storage") behind a Cloudflare zone, without running any image-processing server yourself.
Important
Image transformations must be enabled on your Cloudflare zone before /cdn-cgi/image/ URLs work. See Enable transformations in the Cloudflare docs.
Installation
Install the bridge using Composer and Symfony Flex:
composer require symfony/ux-cloudflare-image
DSN example
UX_IMAGE_DSN=cloudflare://cdn.example.com
The host is the domain proxied by your Cloudflare zone; it must be the domain the origin images are served from.
Parameter mapping
ImageTransformation properties are mapped to Cloudflare's options URL segment:
ImageTransformation |
Cloudflare option | Notes |
|---|---|---|
width |
width |
|
height |
height |
|
fit: Fit::Cover |
fit=cover |
|
fit: Fit::Contain |
fit=contain |
|
format |
format |
format: 'auto' lets Cloudflare pick AVIF/WebP based on the request |
quality |
quality |
|
operations |
(as given) | merged in verbatim, see below |
Supported operations
Any of the following keys can be passed through ImageTransformation::$operations and are forwarded as-is to the Cloudflare URL:
gravity, dpr, rotate, trim, blur, brightness, contrast, gamma, saturation, sharpen, background, border, anim, metadata, onerror, compression.
See the full options reference for what each one does.
Supported formats
avif, webp, jpeg, png.
Cloudflare also supports format=auto, so this provider negotiates the best format for the requesting browser itself: the single <img> of ux_image() still gets a modern format. ux_picture() names each format explicitly instead.