From 1c4b0c52d5223b5787e419953ffa968998091648 Mon Sep 17 00:00:00 2001 From: Amadeus Maximilian <15271679+amxmln@users.noreply.github.com> Date: Fri, 27 Sep 2024 10:52:38 +0200 Subject: [PATCH 1/2] Add info about propertiesToHash to image-service-reference.mdx Local image services have a property `propertiesToHash` which is missing from the docs. This change adds it along with a short explanation of what it does and what it falls back to if not passed. --- src/content/docs/en/reference/image-service-reference.mdx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/content/docs/en/reference/image-service-reference.mdx b/src/content/docs/en/reference/image-service-reference.mdx index 794bef353ae5f..f8cc941777208 100644 --- a/src/content/docs/en/reference/image-service-reference.mdx +++ b/src/content/docs/en/reference/image-service-reference.mdx @@ -116,12 +116,13 @@ const service: LocalImageService = { loading: attributes.loading ?? 'lazy', decoding: attributes.decoding ?? 'async', }; - } + }, + propertiesToHash: ['src', 'width', 'height', 'format', 'quality'], }; export default service; ``` -At build time for static sites and pre-rendered routes, both `` and `getImage(options)` call the `transform()` function. They pass options either through component attributes or an `options` argument, respectively. The transformed images will be built to a `dist/_astro` folder. +At build time for static sites and pre-rendered routes, both `` and `getImage(options)` call the `transform()` function. They pass options either through component attributes or an `options` argument, respectively. The transformed images will be built to a `dist/_astro` folder. Their file names will contain a hash of the properties passed to `propertiesToHash`. This property is optional and will fall back to `['src', 'width', 'height', 'format', 'quality']` if not set. If your custom image service has more options which change the generated images, you should add these to the array. In dev mode and SSR mode, Astro doesn't know ahead of time which images need to be optimized. Astro uses a GET endpoint (by default, `/_image`) to process the images at runtime. `` and `getImage()` pass their options to `getURL()`, which will return the endpoint URL. Then, the endpoint calls `parseURL()` and passes the resulting properties to `transform()`. From 1a305e42ba5abb58d2ea8bb18b89a4a743ceff2c Mon Sep 17 00:00:00 2001 From: Sarah Rainsberger Date: Fri, 27 Sep 2024 11:16:25 -0300 Subject: [PATCH 2/2] tiny grammar fix --- src/content/docs/en/reference/image-service-reference.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/reference/image-service-reference.mdx b/src/content/docs/en/reference/image-service-reference.mdx index f8cc941777208..eca7e2c399501 100644 --- a/src/content/docs/en/reference/image-service-reference.mdx +++ b/src/content/docs/en/reference/image-service-reference.mdx @@ -122,7 +122,7 @@ const service: LocalImageService = { export default service; ``` -At build time for static sites and pre-rendered routes, both `` and `getImage(options)` call the `transform()` function. They pass options either through component attributes or an `options` argument, respectively. The transformed images will be built to a `dist/_astro` folder. Their file names will contain a hash of the properties passed to `propertiesToHash`. This property is optional and will fall back to `['src', 'width', 'height', 'format', 'quality']` if not set. If your custom image service has more options which change the generated images, you should add these to the array. +At build time for static sites and pre-rendered routes, both `` and `getImage(options)` call the `transform()` function. They pass options either through component attributes or an `options` argument, respectively. The transformed images will be built to a `dist/_astro` folder. Their file names will contain a hash of the properties passed to `propertiesToHash`. This property is optional and will default to `['src', 'width', 'height', 'format', 'quality']`. If your custom image service has more options that change the generated images, add these to the array. In dev mode and SSR mode, Astro doesn't know ahead of time which images need to be optimized. Astro uses a GET endpoint (by default, `/_image`) to process the images at runtime. `` and `getImage()` pass their options to `getURL()`, which will return the endpoint URL. Then, the endpoint calls `parseURL()` and passes the resulting properties to `transform()`.