ENF News Bot
Automated News Bot
- Joined
- Apr 15, 2022
- Messages
- 4,544
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
Previously, transformation URLs were not available on
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
The following content appears twice: first for the Cloudflare CLI (
Cloudflare CLI
cloudflare.config.tsts
Wrangler
Set
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
Deployed settings remain active if you remove the configuration. To disable transformation URLs on a Worker, deploy with
Transformation URLs do not require an
Refer to Transform via URL for URL syntax and configuration methods.
Continue reading...
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.pngPreviously, 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:The following content appears twice: first for the Cloudflare CLI (
cf), then for Wrangler. Use cf for new projects. In an existing project, use the CLI that the project already uses.Cloudflare CLI
cloudflare.config.tsts
Code:
import { defineConfig } from "cf/config";
export default defineConfig({
worker: {
name: "image-app",
// Set this to today's date
compatibilityDate: "2026-11-25",
images: {
urlTransformations: {
enabled: true,
allowedOrigins: [
"images.example.com",
"image-app.<YOUR_SUBDOMAIN>.workers.dev",
],
},
},
},
});
Wrangler
Code:
{
"$schema": "./node_modules/wrangler/config-schema.json",
"images": {
"url_transformations": {
"enabled": true,
"allowed_origins": [
"images.example.com",
"image-app.<YOUR_SUBDOMAIN>.workers.dev"
]
}
}
}
Code:
[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.
Continue reading...