Cloudflare Images
Integration between Cloudflare Images and the image module.
/cdn-cgi/image/), use the cloudflare provider instead.Setup
You need your account hash, which you can find in the Cloudflare dashboard under Images > Overview > Developer Resources.
export default defineNuxtConfig({
image: {
cloudflareimages: {
accountHash: 'YOUR_ACCOUNT_HASH'
}
}
})
Images are referenced by their image ID (not a URL path):
<NuxtImg
provider="cloudflareimages"
src="083eb7b2-5392-4565-b69e-aff66acddd00"
width="400"
height="300"
/>
Options
accountHash
Required. Your Cloudflare Images account hash.
baseURL
Default: https://imagedelivery.net/
The base URL for image delivery. You can change this if you are serving images through a custom domain.
Variants vs. flexible transformations
Cloudflare Images supports two ways of serving images:
- Named variants — Predefined sizes configured in the Cloudflare dashboard (e.g.
public,thumbnail). Use thevariantmodifier. - Flexible variants — On-the-fly transformations using width, height, fit, etc. This must be enabled in your Cloudflare Images dashboard.
When you pass a variant modifier or no image modifiers at all, the provider uses the variant URL format. Otherwise, it uses flexible variant transformations.
<!-- Uses the 'public' variant (default when no modifiers) -->
<NuxtImg provider="cloudflareimages" src="my-image-id" />
<!-- Uses a named variant -->
<NuxtImg
provider="cloudflareimages"
src="my-image-id"
:modifiers="{ variant: 'thumbnail' }"
/>
<!-- Uses flexible variants (requires enablement in dashboard) -->
<NuxtImg
provider="cloudflareimages"
src="my-image-id"
width="400"
height="300"
fit="cover"
/>
Modifiers
On top of the standard modifiers, the following Cloudflare Images-specific modifiers are supported when using flexible variants:
| Modifier | Description |
|---|---|
variant | Named variant to use (e.g. public, thumbnail). Takes priority over other modifiers. |
dpr | Device pixel ratio multiplier. |
gravity | Cropping gravity: auto, face, left, right, top, bottom. |
sharpen | Sharpen amount (0-10). |
rotate | Rotation angle: 90, 180, or 270. |
brightness | Brightness adjustment. |
contrast | Contrast adjustment. |
gamma | Gamma adjustment. |
saturation | Saturation adjustment. |
anim | 'true' or 'false' — whether to preserve animation frames. |
metadata | Metadata handling: copyright, keep, or none. |
compression | Set to 'fast' for faster compression. |
flip | Flip image: h (horizontal), v (vertical), or hv (both). |
zoom | Zoom factor for use with gravity: 'face' (0-1). |
fit
| Value | Cloudflare behavior |
|---|---|
cover | Image covers the box, cropping if necessary. |
contain | Image fits inside the box, preserving aspect ratio. |
fill | Pads the image to fill the box. |
outside | Crops the image to fill the box. |
inside | Scales down to fit, never enlarging. |