From 3db1cab620c7fa5c3ad730ed18bf5ebd00f32d63 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Wed, 17 Sep 2025 16:48:24 +0100 Subject: [PATCH] update local images binding docs with vite support --- .../docs/images/transform-images/bindings.mdx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/content/docs/images/transform-images/bindings.mdx b/src/content/docs/images/transform-images/bindings.mdx index b00bb4f4d84527c..43fea048a1f5632 100644 --- a/src/content/docs/images/transform-images/bindings.mdx +++ b/src/content/docs/images/transform-images/bindings.mdx @@ -114,18 +114,33 @@ Wrangler supports two different versions of the Images API: To test the high-fidelity version of Images, you can run `wrangler dev`: -```txt +```sh npx wrangler dev ``` This creates a local-only environment that mirrors the production environment where Cloudflare runs the Images API. You can test your Worker with all available transformation features before deploying to production. -To test the low-fidelity offline version of Images, add the `--experimental-images-local-mode` flag: +To test the low-fidelity offline version of Images, add the `--experimental-images-local-mode` flag when running `wrangler dev`: -```txt +```sh npx wrangler dev --experimental-images-local-mode ``` +Or, set the `imagesLocalMode` experimental option to `true` in your Vite config if you are using the Cloudflare Vite plugin: + +```ts +import { cloudflare } from "@cloudflare/vite-plugin"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [ + cloudflare({ + experimental: { imagesLocalMode: true }, + }), + ], +}); +``` + Currently, this version supports only `width`, `height`, `rotate`, and `format`. When testing with the [Workers Vitest integration](/workers/testing/vitest-integration/), the low-fidelity offline version is used by default, to avoid hitting the Cloudflare API in tests.