Skip to content

Changelog

New updates and improvements at Cloudflare.

Back to all posts

URL-based image optimization in Workers

In Images, you can add optimization parameters directly to transformation URL requests to optimize images from any origin.

Workers now supports the Images URL interface directly on workers.dev subdomains through new Worker-scoped configuration. For example, a Worker can serve this transformation URL without connecting a custom domain:

https://example-app.<YOUR_SUBDOMAIN>.workers.dev/cdn-cgi/image/format=auto,width=400/image.png

Previously, transformation URLs were not available on workers.dev subdomains or during local development. A Worker could serve transformation URLs only through a connected custom domain when the URL interface was enabled for that zone.

The new Worker-scoped settings apply to deployed Workers and during local development. On connected custom domains, they override the zone-scoped settings.

Configure the settings in your Wrangler configuration file or in cloudflare.config.ts for Cloudflare CLI:

cloudflare.config.tsts
import { defineConfig } from "cf/config";

export default defineConfig({
worker: {
  name: "image-app",
  // Set this to today's date
  compatibilityDate: "2026-12-01",
  images: {
    urlTransformations: {
      enabled: true,
      allowedOrigins: [
        "images.example.com",
        "image-app.<YOUR_SUBDOMAIN>.workers.dev",
      ],
    },
  },
},
});
{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "images": {
    "url_transformations": {
      "enabled": true,
      "allowed_origins": [
        "images.example.com",
        "image-app.<YOUR_SUBDOMAIN>.workers.dev"
      ]
    }
  }
}
[images.url_transformations]
enabled = true
allowed_origins = [
  "images.example.com",
  "image-app.<YOUR_SUBDOMAIN>.workers.dev",
]

Set enabled to true to turn on transformation URLs.

By default, Workers accepts source images only from the same zone as the transformation URL. To use external source images, specify up to 10 hostnames using allowed_origins in Wrangler or allowedOrigins in cloudflare.config.ts.

Deployed settings remain active if you remove the configuration. To disable transformation URLs on a Worker, deploy with enabled set to false. Named Wrangler environments require their own configuration, and Version URLs support transformation URLs using the Worker's deployed settings.

wrangler deploy and cf deploy apply the same settings to the Worker, while wrangler dev and cf dev use them locally.

Transformation URLs do not require an IMAGES binding. Transformed results are automatically cached in production.

Refer to Transform via URL for URL syntax and configuration methods.