skip to content

In Cloudflare Images hosted storage, how do named variants, flexible variants and signed URLs decide which versions of an image a browser can fetch?

level: middleimportance: should knowfreq 20%

answer

  1. account hash, image ID, variant
  2. public is the default variant
  3. flexible variants are off by default
  4. requireSignedURLs at upload
  5. exp plus sig, signed server-side

basics

~20 s

A hosted image is served as imagedelivery.net/<ACCOUNT_HASH>/<IMAGE_ID>/<VARIANT>. Named variants fix the sizes on offer, flexible variants (off by default) allow any parameters in the URL, and requireSignedURLs makes an image need an expiring signed URL.

solid answer

~40 s

Hosted images are served from `https://imagedelivery.net/<ACCOUNT_HASH>/<IMAGE_ID>/<VARIANT>`, or from `/cdn-cgi/imagedelivery/...` on a domain in the same account. A **named variant** fixes width, height, fit and blur; every account starts with `public` and can define up to 100. **Flexible variants** are off by default; once on, any parameters can go in the URL (`w=400,sharpen=3`), but never for images that require signed URLs. An image uploaded with `requireSignedURLs: true` is served only with a URL carrying `exp` and an HMAC-SHA256 `sig` made with the account's signing key on your server, or, since September 2026, minted by the binding's `env.IMAGES.hosted.image(id).signedUrl()` without the Worker handling the key. A variant marked **Always allow public access** stays public even for private images. Images with a custom ID cannot be made private.

go deeper

for a junior

Recall the delivery URL parts and that public is the default variant, with named variants as the menu of sizes.

for a middle

Explain how flexible variants, requireSignedURLs and always-public variants interact, and how exp and sig make a signed URL.

for a senior

Show the operational care: keep the signing key server-side or use signedUrl(), set sensible expiries, and avoid custom IDs for anything that must become private.

for a principal

Decide which images a product makes private, which variants stay public, and whether free-form sizing is worth giving up the fixed menu.

## Hosted images and their URLs Besides transforming remote images, Cloudflare Images can **store** originals (an Images Paid plan feature). A **hosted image** gets an image ID, either a generated UUID or a custom ID, and is served through a delivery URL: ```plaintext https://imagedelivery.net/<ACCOUNT_HASH>/<IMAGE_ID>/<VARIANT_NAME> https://shop.example/cdn-cgi/imagedelivery/<ACCOUNT_HASH>/<IMAGE_ID>/<VARIANT_NAME> ``` The second form works on any proxied domain in the same account. Hosted delivery defaults to automatic format: AVIF where the browser supports it, then WebP, otherwise the original format; SVGs are sanitized rather than resized. ## Named variants: a fixed menu A **variant** is a named recipe. Predefined variants specify a limited set of parameters, `width`, `height`, `fit` and `blur`, plus a metadata choice. Every account has `public`, and up to **100** variants can be created in the dashboard (**Hosted Images > Delivery**) or through the variants API. - A marketplace defines `thumb`, `card` and `zoom`, so pages can only ask for those sizes. - Each variant can set its own Browser TTL; the account default is two days. - Defining variants does not count toward Images Stored; only uploaded images do. ## Flexible variants: any size in the URL **Flexible variants** are **off by default**. Turning them on (in the dashboard or with `flexible_variants: true` on the Images config endpoint) lets any optimization parameter go in place of the variant name, such as `.../<IMAGE_ID>/w=400,sharpen=3`. That is convenient, but it reopens free-form sizing, including requests for large renditions. And **flexible variants cannot be used for images that require a signed delivery URL.** ## Private images and signed URLs An image becomes private when `requireSignedURLs` is `true`. It defaults to `false` and can be set on upload, on a Direct Creator Upload URL, or later through an update. Images uploaded with a **custom ID cannot be made private**. A private image is fetched only with a **signed URL**: 1. Take the delivery URL, for example `.../<IMAGE_ID>/card`. 2. Add `exp=<unix seconds>` for the expiry. 3. Compute HMAC-SHA256 over the path plus `?exp=...` with the account's **signing key** (Hosted Images > Keys) and append it as `sig=<hex>`. This runs on your server: the signing key is a secret, stored for example with `wrangler secret put`, and never reaches the browser. Since September 2026 a Worker can instead call `env.IMAGES.hosted.image(id).signedUrl({ variant: "card", expiresIn: 3600 })`; the URL is signed on Cloudflare's side, so the Worker never holds the key. Omitting `expiresIn` produces a URL that does not expire, which is rarely what a private image wants. | Control | Default | Effect | |---|---|---| | `requireSignedURLs` | `false` | image needs `exp` + `sig` | | Always allow public access on a variant | off | that variant stays public for private images | | Flexible variants | off | free-form parameters, never for signed images | | Browser TTL | two days | private images ignore it and follow the signature's expiry, as short as one hour | The **Always allow public access** flag (`neverRequireSignedURLs` in the API) suits a blurred teaser: a seller's draft listing stays private at `card` and `zoom` while a public `blurred` variant can appear in search results. ## Making images private from the first byte Privacy is easiest to get right at upload time. With **Direct Creator Upload**, the backend asks Cloudflare for a one-time upload URL and hands only that URL to the seller's browser, so the API token never leaves the server. The request can set `requireSignedURLs` for the image that will arrive there, and the binding's `.createDirectUpload()` takes the same flag plus `expiresIn`, between 120 and 21,600 seconds, default 1,800. - Hosted uploads are limited to **10 MB** per file and 1,024 bytes of metadata. - Metadata attached at upload is never shared with end users. - A draft record exists from the moment the URL is issued, and turns into a normal image once the upload completes. Publishing a listing can then flip `requireSignedURLs` to `false` with an update, or leave the originals private and expose only an always-public variant. ## How this differs from transformations Signed URLs are a hosted-images feature. Remote-image transformations are cached publicly, and Cloudflare advises against resizing per-visitor private images through them. Billing differs too: serving a hosted image through its delivery URL counts toward **Images Delivered** ($1 per 100,000), not Images Transformed.

  • Why should a signed Cloudflare Images URL be generated on the server rather than in the browser?
    The signature is an HMAC over the path and `exp` using the account's signing key. Anyone holding that key can sign any image for any expiry, so it lives in a server-side secret, or the Worker uses the binding's `.signedUrl()` and never sees the key at all.
  • A team turns on flexible variants for convenience; what do they give up?
    The fixed menu of sizes: any visitor can now put parameters in the URL, including large renditions. Images that require signed URLs cannot use flexible variants at all, so private images still need named variants.

A signed delivery URL works like a cloakroom ticket stamped with a closing time: the attendant checks the stamp and the punch, not who is holding it, so anyone with the ticket before closing gets the coat.

  • Using flexible variant URLs for images that require signed URLs
  • Embedding the Images signing key in front-end code to sign URLs
  • Expecting a custom-ID image to become private with requireSignedURLs
  • Believing variants count against the stored images allowance
  • Thinking a signed URL proves which user is viewing the image

Assumes Cloudflare's platform as of 2026-10-10: the binding's hosted namespace arrived in June 2026 and .signedUrl() in September 2026; before, signed URLs were built only with your own HMAC code and the signing key.