Skip to content

ImagesVariant

Source: src/Cloudflare/Images/Variant.ts

A Cloudflare Images variant — a named resizing preset (e.g. thumbnail, hero) applied when serving images from Cloudflare Images.

A variant is identified by its name within an account (up to 100 variants per account). The name is the URL segment used to request the variant, so it is immutable — changing it triggers a replacement. All resizing options (fit, width, height, metadata, neverRequireSignedURLs) are mutable in place.

Note: every Images-enabled account has a built-in public variant. Do not manage public with this resource — Cloudflare silently ignores deletes of the built-in variant, so destroy would not actually remove it.

Thumbnail variant

// Variant names are alphanumeric only (no hyphens/underscores).
const thumbnail = yield* Cloudflare.ImagesVariant("thumbnail", {
fit: "cover",
width: 100,
height: 100,
});

Hero variant with explicit name and metadata

const hero = yield* Cloudflare.ImagesVariant("HeroImage", {
name: "hero",
fit: "scale-down",
width: 1920,
height: 1080,
metadata: "copyright",
});
// Serve this variant without a signature even when the image itself
// requires signed URLs (e.g. for public thumbnails of private images).
const preview = yield* Cloudflare.ImagesVariant("preview", {
fit: "contain",
width: 320,
height: 240,
neverRequireSignedURLs: true,
});