diff --git a/astro.sidebar.ts b/astro.sidebar.ts
index 6c167dfce705b..f63bdd2c8bb37 100644
--- a/astro.sidebar.ts
+++ b/astro.sidebar.ts
@@ -136,13 +136,13 @@ export const sidebar = [
group('reference.experimental', {
items: [
'reference/experimental-flags',
- 'reference/experimental-flags/responsive-images',
'reference/experimental-flags/fonts',
'reference/experimental-flags/client-prerender',
'reference/experimental-flags/content-intellisense',
'reference/experimental-flags/preserve-scripts-order',
'reference/experimental-flags/heading-id-compat',
'reference/experimental-flags/csp',
+ 'reference/experimental-flags/live-content-collections',
],
}),
'reference/legacy-flags',
diff --git a/public/_redirects b/public/_redirects
index 78350a6089539..e9bb707197995 100644
--- a/public/_redirects
+++ b/public/_redirects
@@ -38,6 +38,8 @@
/:lang/reference/experimental-flags/sessions/ /:lang/guides/sessions/
/:lang/reference/experimental-flags/svg/ /:lang/guides/images/
/:lang/reference/experimental-flags/serialized-configuration/ /:lang/reference/modules/astro-config/
+/:lang/reference/experimental-flags/responsive-images/ /:lang/guides/images/
+
# Very old docs site redirects
# Once upon a time these URLs existed, so we try to keep them meaning something.
diff --git a/src/content/docs/en/guides/images.mdx b/src/content/docs/en/guides/images.mdx
index b17ea2047be86..07de60c1fb47d 100644
--- a/src/content/docs/en/guides/images.mdx
+++ b/src/content/docs/en/guides/images.mdx
@@ -11,7 +11,7 @@ import ReadMore from '~/components/ReadMore.astro';
Astro provides several ways for you to use images on your site, whether they are stored locally inside your project, linked to from an external URL, or managed in a CMS or CDN.
-Astro provides [image](#display-optimized-images-with-the-image--component) and [picture](#create-responsive-images-with-the-picture--component) components, [Markdown image syntax](#images-in-markdown-files) processing, [SVG components](#svg-components), and [an image generating function](#generating-images-with-getimage) to optimize and/or transform your images.
+Astro provides [image](#image-) and [picture](#picture-) components, [Markdown image syntax](#images-in-markdown-files) processing, [SVG components](#svg-components), and [an image generating function](#generating-images-with-getimage) to optimize and/or transform your images. Additionally, you can configure [automatically resizing responsive images](#responsive-image-behavior) by default, or set responsive properties on individual image and picture components.
You can always choose to use images and SVG files using native HTML elements in `.astro` or Markdown files, or the standard way for your file type (e.g. ` ` in MDX and JSX). However, Astro does not perform any processing or optimization of these images.
@@ -21,26 +21,40 @@ You can always choose to use images and SVG files using native HTML elements in
### `src/` vs `public/`
-We recommend that local images are kept in `src/` when possible so that Astro can transform, optimize and bundle them. Files in the `/public` directory are always served or copied into the build folder as-is, with no processing.
+We recommend that local images are kept in `src/` when possible so that Astro can transform, optimize, and bundle them. Files in the `public/` directory are always served or copied into the build folder as-is, with no processing.
-Your local images stored in `src/` can be used by all files in your project: `.astro`, `.md`, `.mdx`, `.mdoc`, and other UI frameworks. Images can be stored in any folder, including alongside your content.
+Your local images stored in `src/` can be used by all files in your project: `.astro`, `.md`, `.mdx`, `.mdoc`, and other UI frameworks as file imports. Images can be stored in any folder, including alongside your content.
-Store your images in the `public/` folder if you want to avoid any processing or to have a direct public link to them.
+Store your images in the `public/` folder if you want to avoid any processing. These images are available to your project files as URL paths on your domain and allow you to have a direct public link to them. For example, your site favicon will commonly be placed in the root of this folder where browsers can identify it.
### Remote images
-You can also choose to store your images remotely, in a [content management system (CMS)](/en/guides/cms/) or [digital asset management (DAM)](/en/guides/media/) platform.
-Astro can fetch your data remotely using APIs or display images from their full URL path.
+You can also choose to store your images remotely, in a [content management system (CMS)](/en/guides/cms/) or [digital asset management (DAM)](/en/guides/media/) platform. Astro can fetch your data remotely using APIs or display images from their full URL path.
For extra protection when dealing with external sources, Astro's image components and helper function will only process (e.g. optimize, transform) images from [authorized image sources specified in your configuration](#authorizing-remote-images). Remote images from other sources will be displayed with no processing.
## Images in `.astro` files
-In `.astro` files, a local image must be imported from its relative path. This import provides the `src` value for your image.
+
-Remote and `public/` images do not require importing, and instead require a URL (full, or relative path on your site) for `src`.
+**Options:** ` `, ` `, ` `, ``, SVG components
+
-Import and use Astro's native [` `](#display-optimized-images-with-the-image--component) and [` `](#create-responsive-images-with-the-picture--component) components for optimized images. Astro syntax also supports [writing an HTML ` ` tag directly](#display-unprocessed-images-with-the-html-img-tag), which skips image processing.
+Astro's templating language allows you to render optimized images with the Astro [` `](/en/reference/modules/astro-assets/#image-) component and generate multiple sizes and formats with the Astro [` `](/en/reference/modules/astro-assets/#picture-) component. Both components also accept [responsive image properties](#responsive-image-behavior) for resizing based on container size and responding to device screen size and resolution.
+
+Additionally, you can import and use [SVG files as Astro components](#svg-components) in `.astro` components.
+
+All native HTML tags, including ` ` and ``, are also available in `.astro` components. [Images rendered with HTML tags](#display-unprocessed-images-with-the-html-img-tag) will not be processed (e.g. optimized, transformed) and will be copied into your build folder as-is.
+
+For all images in `.astro` files, **the value of the image `src` attribute is determined by the location of your image file**:
+
+- A local image from your project `src/` folder uses an import from the file's relative path.
+
+ The image and picture components use the named import directly (e.g. `src={rocket}`), while the ` ` tag uses the `src` object property of the import (e.g. `src={rocket.src}`).
+
+- Remote and `public/` images use a URL path.
+
+ Provide a full URL for remote images (e.g. `src="https://www.example.com/images/my-remote-image.jpg"`), or a relative URL path on your site that corresponds to your file's location in your `public/` folder (e.g. `src="/images/my-public-image.jpg"` for an image located in `public/images/my-public-image.jpg`).
```astro title="src/pages/blog/my-images.astro"
---
@@ -56,11 +70,136 @@ import localBirdImage from '../../images/subfolder/localBirdImage.png';
```
-See the full API reference for the [` `](/en/reference/modules/astro-assets/#image-) and [` `](/en/reference/modules/astro-assets/#picture-) components.
+See the full API reference for the [` `](/en/reference/modules/astro-assets/#image-) and [` `](/en/reference/modules/astro-assets/#picture-) components including required and optional properties.
-### Display optimized images with the ` ` component
+
+## Images in Markdown files
+
+
+
+**Options:** `![]()`, ` ` (with public or remote images)
+
+
+Use standard Markdown `` syntax in your `.md` files. Your local images stored in `src/` and remote images will be processed and optimized. When you [configure responsive images globally](/en/reference/configuration-reference/#imagelayout), these images will also be [responsive](#responsive-image-behavior).
+
+Images stored in the `public/` folder are never optimized.
+
+```md
+
+
+# My Markdown Page
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+The HTML ` ` tag can also be used to display images stored in `public/` or remote images without any image optimization or processing. However, ` ` is not supported for your local images in `src`.
+
+The ` ` and ` ` components are unavailable in `.md` files. If you require more control over your image attributes, we recommend using [Astro's MDX integration](/en/guides/integrations-guide/mdx/) to add support for `.mdx` file format. MDX allows additional [image options available in MDX](#images-in-mdx-files), including combining components with Markdown syntax.
+
+## Images in MDX files
+
+
+
+**Options:** ` `, ` `, ` `, `![]()`, SVG components
+
+
+You can use Astro's ` ` and ` ` components in your `.mdx` files by importing both the component and your image. Use them just as they are [used in `.astro` files](#images-in-astro-files). The JSX ` ` tag is also supported for unprocessed images and [uses the same image import as the HTML ` ` tag](#display-unprocessed-images-with-the-html-img-tag).
+
+Additionally, there is support for [standard Markdown `` syntax](#images-in-markdown-files) with no import required.
+
+```mdx title="src/pages/post-1.mdx"
+---
+title: My Page title
+---
+import { Image } from 'astro:assets';
+import rocket from '../assets/rocket.png';
+
+# My MDX Page
+
+// Local image stored in the the same folder
+
+
+// Local image stored in src/assets/
+
+
+
+
+// Image stored in public/images/
+
+
+
+
+// Remote image on another server
+
+
+
+
+```
+
+See the full API reference for the [` `](/en/reference/modules/astro-assets/#image-) and [` `](/en/reference/modules/astro-assets/#picture-) components.
+
+## Images in UI framework components
+
+
+
+**Image options:** the framework's own image syntax (e.g. ` ` in JSX, ` ` in Svelte)
+
+
+[Local images must first be imported](#display-unprocessed-images-with-the-html-img-tag) to access their image properties such as `src`. Then, they can be rendered as you normally would in that framework's own image syntax:
+
+```jsx title="src/components/ReactImage.jsx"
+import stars from "../assets/stars.png";
+
+export default function ReactImage() {
+ return (
+
+ )
+}
+```
+
+```svelte title="src/components/SvelteImage.svelte"
+
+
+
+
+```
+
+Astro components (e.g. ` `, ` `, SVG components) are unavailable inside UI framework components because [a client island must contain only valid code for its own framework](/en/guides/framework-components/#can-i-use-astro-components-inside-my-framework-components).
+
+But, you can pass the static content generated by these components to a framework component inside a `.astro` file [as children](/en/guides/framework-components/#passing-children-to-framework-components) or using a [named ` `](/en/guides/framework-components/#can-i-use-astro-components-inside-my-framework-components):
+
+
+```astro title="src/components/ImageWrapper.astro"
+---
+import ReactComponent from './ReactComponent.jsx';
+import { Image } from 'astro:assets';
+import stars from '~/stars/docline.png';
+---
+
+
+
+
+```
+
+## Astro components for images
+
+Astro provides two built-in Astro components for images (` ` and ` `) and also allows you to import SVG files and use them as Astro components. These components may be used in any files that can import and render `.astro` components.
+
+### ` `
Use the built-in ` ` Astro component to display optimized versions of:
@@ -137,11 +276,14 @@ You can also use the ` ` component for images in the `public/` folder, o
However, using the image component for all images provides a consistent authoring experience and prevents Cumulative Layout Shift (CLS) even for your unoptimized images.
:::
-### Create responsive images with the ` ` component
+
+### ` `
-Use the built-in ` ` Astro component to display a responsive image with multiple formats and/or sizes. Like the [` ` component](#display-optimized-images-with-the-image--component), images will be processed at build time for prerendered pages. When your page is rendered on demand, processing will occur on the fly when the page is viewed.
+Use the built-in ` ` Astro component to generate a `` tag with multiple formats and/or sizes of your image. This allows you to specify preferred file formats to display and at the same time, provide a fallback format. Like the [` ` component](#image-), images will be processed at build time for prerendered pages. When your page is rendered on demand, processing will occur on the fly when the page is viewed.
+
+The following example uses the ` ` component to transform a local `.png` file into a web-friendly `avif` and `webp` format as well as the `.png` ` ` that can be displayed as a fallback when needed:
```astro title="src/pages/index.astro"
---
@@ -171,109 +313,95 @@ import myImage from '../assets/my_image.png'; // Image is 1600x900
See details about [the ` ` component properties](/en/reference/modules/astro-assets/#picture-properties) in the `astro:assets` reference.
-### Display unprocessed images with the HTML ` ` tag
+### Responsive image behavior
-The [Astro template syntax](/en/reference/astro-syntax/) also supports writing an ` ` tag directly, with full control over its final output. These images will not be processed and optimized. It accepts all HTML ` ` tag properties, and the only required property is `src`.
+
-Local images must be imported from the relative path from the existing `.astro` file, or you can configure and use an [import alias](/en/guides/imports/#aliases). Then, you can access the image's `src` and other properties to use in the ` ` tag.
+Responsive images are images that adjust to improve performance across different devices. These images can resize to fit their container, and can be served in different sizes depending on your visitor's screen size and resolution.
-Imported image assets match the following signature:
+With [responsive image properties](/en/reference/modules/astro-assets/#responsive-image-properties) applied to the ` ` or ` ` components, Astro will automatically generate the required `srcset` and `sizes` values for your images, and apply the necessary [styles to ensure they resize correctly](#responsive-image-styles).
-```ts
-interface ImageMetadata {
- src: string;
- width: number;
- height: number;
- format: string;
-}
-```
+When this responsive behavior is [configured globally](/en/reference/configuration-reference/#imagelayout), it will apply to all image components and also to any local and remote images using [the Markdown `![]()` syntax](/en/guides/images/#images-in-markdown-files).
-The following example uses the image's own `height` and `width` properties to avoid Cumulative Layout Shift (CLS) and improve Core Web Vitals:
+Images in your `public/` folder are never optimized, and responsive images are not supported.
-```astro title="src/pages/posts/post-1.astro" "myDog.width" "myDog.height"
----
-// import local images
-import myDog from '../../images/pets/local-dog.jpg';
----
-// access the image properties
-
-```
-
-#### Images in `public/`
-For images located within `public/` use the image's file path relative to the public folder as the `src` value:
-
-```astro '"/images/public-cat.jpg"'
-
-```
-
-#### Remote images
-
-For remote images, use the image's full URL as the `src` value:
-
-```astro '"https://example.com/remote-cat.jpg"'
-
-```
-
-### Choosing ` ` vs ` `
+:::note
+A single responsive image will generate multiple images of different sizes so that the browser can show the best one to your visitor.
-The ` ` component optimizes your image and infers width and height (for images it can process) based on the original aspect ratio to avoid CLS. It is the preferred way to use images in `.astro` files whenever possible.
+For prerendered pages, this happens during the build and may increase the build time of your project, especially if you have a large number of images.
-Use the HTML ` ` element when you cannot use the ` ` component, for example:
- - for unsupported image formats
- - when you do not want your image optimized by Astro
- - to access and change the `src` attribute dynamically client-side
+For pages rendered on-demand, the images are generated as-needed when a page is visited. This has no impact on build times but may increase the number of image transformations performed when an image is displayed. Depending on your image service this may incur additional costs.
+:::
-### Setting Default Values
+Read more about [responsive images on MDN web docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images).
-Currently, there is no way to specify default values for all ` ` or ` ` components. Required attributes should be set on each individual component.
+#### Generated HTML output for responsive images
-As an alternative, you can wrap these components in another Astro component for reuse. For example, you could create a component for your blog post images that receives attributes as props and applies consistent styles to each image:
+When a layout is set, either by default or on an individual component, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `constrained` and `full-width` layouts will have styles applied to ensure they resize according to their container.
-```astro title="src/components/BlogPostImage.astro"
+```astro title="src/components/MyComponent.astro"
---
import { Image } from 'astro:assets';
-
-const { src, ...attrs } = Astro.props;
+import myImage from '../assets/my_image.png';
---
-
+
+```
-
+This ` ` component will generate the following HTML output on a prerendered page:
+
+```html
+
```
-### Authorizing remote images
+#### Responsive image styles
-You can configure lists of authorized image source URL domains and patterns for image optimization using [`image.domains`](/en/reference/configuration-reference/#imagedomains) and [`image.remotePatterns`](/en/reference/configuration-reference/#imageremotepatterns). This configuration is an extra layer of safety to protect your site when showing images from an external source.
+Setting [`image.responsiveStyles: true`](/en/reference/configuration-reference/#imageresponsivestyles) applies a small number of global styles to ensure that your images resize correctly. In most cases, you will want to enable these as a default; your images will not be responsive without additional styles.
-Remote images from other sources will not be optimized, but using the ` ` component for these images will prevent Cumulative Layout Shift (CLS).
+However, if you prefer to handle responsive image styling yourself, or need to [override these defaults when using Tailwind 4](#responsive-images-with-tailwind-4), leave the default `false` value configured.
-For example, the following configuration will only allow remote images from `astro.build` to be optimized:
+The global styles applied by Astro will depend on the layout type, and are designed to produce the best result for the generated `srcset` and `sizes` attributes. These are the default styles:
-```ts
-// astro.config.mjs
-export default defineConfig({
- image: {
- domains: ["astro.build"],
- }
-});
+```css title="Responsive Image Styles"
+:where([data-astro-image]) {
+ object-fit: var(--fit);
+ object-position: var(--pos);
+}
+:where([data-astro-image='full-width']) {
+ width: 100%;
+}
+:where([data-astro-image='constrained']) {
+ max-width: 100%;
+}
```
-The following configuration will only allow remote images from HTTPS hosts:
+The styles use the [`:where()` pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:where), which has a [specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascade/Specificity) of 0, meaning that it is easy to override with your own styles. Any CSS selector will have a higher specificity than `:where()`, so you can easily override the styles by adding your own styles to target the image.
-```ts
-// astro.config.mjs
-export default defineConfig({
- image: {
- remotePatterns: [{ protocol: "https" }],
- }
-});
-```
+You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the ` ` or ` ` component.
+
+#### Responsive images with Tailwind 4
-## SVG components
+Tailwind 4 is compatible with Astro's default responsive styles. However, Tailwind uses [cascade layers](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer), meaning that its rules are always lower specificity than rules that don't use layers, including Astro's responsive styles. Therefore, Astro's styling will take precedence over Tailwind styling. To use Tailwind rules instead of Astro's default styling, do not enable [Astro's default responsive styles](/en/reference/configuration-reference/#imageresponsivestyles).
+
+
+### SVG components
Astro allows you to import SVG files and use them as Astro components. Astro will inline the SVG content into your HTML output.
@@ -290,7 +418,7 @@ import Logo from './path/to/svg/file.svg';
Your SVG component, like ` ` or any other Astro component, is unavailable inside UI framework components, but can [be passed to a framework component](#images-in-ui-framework-components) inside a `.astro` component.
-### SVG component attributes
+#### SVG component attributes
You can pass props such as `width`, `height`, `fill`, `stroke`, and any other attribute accepted by the [native `` element](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg). These attributes will automatically be applied to the underlying `` element. If a property is present in the original `.svg` file and is passed to the component, the value passed to the component will override the original value.
@@ -303,82 +431,122 @@ import Logo from '../assets/logo.svg';
```
-## Using Images from a CMS or CDN
+### Creating custom image components
-Image CDNs work with [all Astro image options](#images-in-astro-files). Use an image's full URL as the `src` attribute in the ` ` component, an ` ` tag, or in Markdown notation. For image optimization with remote images, also [configure your authorized domains or URL patterns](#authorizing-remote-images).
+You can create a custom, reusable image component by wrapping the ` ` or ` ` component in another Astro component. This allows you to set default attributes and styles only once.
-Alternatively, the CDN may provide its own SDKs to more easily integrate in an Astro project. For example, Cloudinary supports an [Astro SDK](https://astro.cloudinary.dev/) which allows you to easily drop in images with their `CldImage` component or a [Node.js SDK](https://cloudinary.com/documentation/node_integration) that can generate URLs to use with an ` ` tag in a Node.js environment.
+For example, you could create a component for your blog post images that receives attributes as props and applies consistent styles to each image:
-See the full API reference for the [` `](/en/reference/modules/astro-assets/#image-) and [` `](/en/reference/modules/astro-assets/#picture-) components.
+```astro title="src/components/BlogPostImage.astro"
+---
+import { Image } from 'astro:assets';
-## Images in Markdown files
+const { src, ...attrs } = Astro.props;
+---
+
-Use standard Markdown `` syntax in your `.md` files. This syntax works with Astro's [Image Service API](/en/reference/image-service-reference/) to optimize your local images stored in `src/` and remote images. Images stored in the `public/` folder are never optimized.
+
+```
-```md
-
+## Display unprocessed images with the HTML ` ` tag
-# My Markdown Page
+The [Astro template syntax](/en/reference/astro-syntax/) also supports writing an ` ` tag directly, with full control over its final output. These images will not be processed and optimized. It accepts all HTML ` ` tag properties, and the only required property is `src`. However, it is strongly recommended to include [the `alt` property for accessibility](#alt-text).
-
-
-
+### images in `src/`
-
-
-
+Local images must be imported from the relative path from the existing `.astro` file, or you can configure and use an [import alias](/en/guides/imports/#aliases). Then, you can access the image's `src` and other properties to use in the ` ` tag.
-
-
-
+Imported image assets match the following signature:
+
+```ts
+interface ImageMetadata {
+ src: string;
+ width: number;
+ height: number;
+ format: string;
+}
```
-The HTML ` ` tag can also be used to display images stored in `public/` or remote images without any image optimization or processing. However, ` ` is not supported for your local images in `src`.
+The following example uses the image's own `height` and `width` properties to avoid Cumulative Layout Shift (CLS) and improve Core Web Vitals:
-The ` ` and ` ` components are unavailable in `.md` files. If you require more control over your image attributes, we recommend using [Astro's MDX integration](/en/guides/integrations-guide/mdx/) to add support for `.mdx` file format. MDX allows additional [image options available in MDX](#images-in-mdx-files), including combining components with Markdown syntax.
+```astro title="src/pages/posts/post-1.astro" "myDog.width" "myDog.height"
+---
+// import local images
+import myDog from '../../images/pets/local-dog.jpg';
+---
+// access the image properties
+
+```
-## Images in MDX files
+### Images in `public/`
+For images located within `public/` use the image's file path relative to the public folder as the `src` value:
-You can use Astro's ` ` and ` ` components in your `.mdx` files by importing both the component and your image. Use them just as they are [used in `.astro` files](#images-in-astro-files). The JSX ` ` tag is also supported for unprocessed images and [uses the same image import as the HTML ` ` tag](#display-unprocessed-images-with-the-html-img-tag).
+```astro '"/images/public-cat.jpg"'
+
+```
-Additionally, there is support for [standard Markdown `` syntax](#images-in-markdown-files) with no import required.
+### Remote images
-```mdx title="src/pages/post-1.mdx"
----
-title: My Page title
----
-import { Image } from 'astro:assets';
-import rocket from '../assets/rocket.png';
+For remote images, use the image's full URL as the `src` value:
-# My MDX Page
+```astro '"https://example.com/remote-cat.jpg"'
+
+```
-// Local image stored in the the same folder
-
+### Choosing ` ` vs ` `
-// Local image stored in src/assets/
-
-
-
+The ` ` component optimizes your image and infers width and height (for images it can process) based on the original aspect ratio to avoid CLS. It is the preferred way to use images in `.astro` files whenever possible.
-// Image stored in public/images/
-
-
-
+Use the HTML ` ` element when you cannot use the ` ` component, for example:
+ - for unsupported image formats
+ - when you do not want your image optimized by Astro
+ - to access and change the `src` attribute dynamically client-side
-// Remote image on another server
-
-
-
-```
+## Using Images from a CMS or CDN
+
+Image CDNs work with [all Astro image options](#images-in-astro-files). Use an image's full URL as the `src` attribute in the ` ` component, an ` ` tag, or in Markdown notation. For image optimization with remote images, also [configure your authorized domains or URL patterns](#authorizing-remote-images).
+
+Alternatively, the CDN may provide its own SDKs to more easily integrate in an Astro project. For example, Cloudinary supports an [Astro SDK](https://astro.cloudinary.dev/) which allows you to easily drop in images with their `CldImage` component or a [Node.js SDK](https://cloudinary.com/documentation/node_integration) that can generate URLs to use with an ` ` tag in a Node.js environment.
See the full API reference for the [` `](/en/reference/modules/astro-assets/#image-) and [` `](/en/reference/modules/astro-assets/#picture-) components.
-## Images in content collections
+## Authorizing remote images
-Images in content collections will be processed the same way they are in [Markdown](#images-in-markdown-files) and [MDX](#images-in-mdx-files) depending on which file type you are using.
+You can configure lists of authorized image source URL domains and patterns for image optimization using [`image.domains`](/en/reference/configuration-reference/#imagedomains) and [`image.remotePatterns`](/en/reference/configuration-reference/#imageremotepatterns). This configuration is an extra layer of safety to protect your site when showing images from an external source.
+
+Remote images from other sources will not be optimized, but using the ` ` component for these images will prevent Cumulative Layout Shift (CLS).
-Additionally, you can declare an associated image for a content collections entry, such as a blog post's cover image, in your frontmatter using its path relative to the current folder:
+For example, the following configuration will only allow remote images from `astro.build` to be optimized:
+
+```ts
+// astro.config.mjs
+export default defineConfig({
+ image: {
+ domains: ["astro.build"],
+ }
+});
+```
+
+The following configuration will only allow remote images from HTTPS hosts:
+
+```ts
+// astro.config.mjs
+export default defineConfig({
+ image: {
+ remotePatterns: [{ protocol: "https" }],
+ }
+});
+```
+
+## Images in content collections
+
+You can declare an associated image for a content collections entry, such as a blog post's cover image, in your frontmatter using its path relative to the current folder:
```md title="src/content/blog/my-post.md" {3}
---
@@ -408,9 +576,9 @@ export const collections = {
};
```
-The image will be imported and transformed into metadata, allowing you to pass it as a `src` to ` `, ` `, or `getImage()`.
+The image will be imported and transformed into metadata, allowing you to pass it as a `src` to ` `, ` `, or `getImage()` in an Astro component.
-The example below shows a blog index page that renders the cover photo and title of each blog post from the schema above:
+The example below shows a blog index page that renders the cover photo and title of each blog post from the previous schema:
```astro title="src/pages/blog.astro" {10}
---
@@ -431,48 +599,6 @@ const allBlogPosts = await getCollection("blog");
}
```
-## Images in UI framework components
-
-The ` ` component, like any other Astro component, is unavailable inside UI framework components.
-
-But, you can pass the static content generated by ` ` to a framework component inside a `.astro` file [as children](/en/guides/framework-components/#passing-children-to-framework-components) or using a [named ` `](/en/guides/framework-components/#can-i-use-astro-components-inside-my-framework-components):
-
-
-```astro title="src/components/ImageWrapper.astro"
----
-import ReactComponent from './ReactComponent.jsx';
-import { Image } from 'astro:assets';
-import stars from '~/stars/docline.png';
----
-
-
-
-
-```
-
-You can also use the framework's own image syntax to render an image (e.g. ` ` in JSX, ` ` in Svelte).
-
-[Local images must first be imported](#display-unprocessed-images-with-the-html-img-tag) to access their image properties such as `src`.
-
-```jsx title="src/components/ReactImage.jsx"
-import stars from "../assets/stars.png";
-
-export default function ReactImage() {
- return (
-
- )
-}
-```
-
-```svelte title="src/components/SvelteImage.svelte"
-
-
-
-
-```
-
## Generating images with `getImage()`
The `getImage()` function is intended for generating images destined to be used somewhere else than directly in HTML, for example in an [API Route](/en/guides/endpoints/#server-endpoints-api-routes). When you need options that the `` and `` components do not currently support, you can use the `getImage()` function to create your own custom ` ` component.
diff --git a/src/content/docs/en/guides/integrations-guide/cloudflare.mdx b/src/content/docs/en/guides/integrations-guide/cloudflare.mdx
index d3c30ec4b033b..8747da9301388 100644
--- a/src/content/docs/en/guides/integrations-guide/cloudflare.mdx
+++ b/src/content/docs/en/guides/integrations-guide/cloudflare.mdx
@@ -248,6 +248,98 @@ export default defineConfig({
});
```
+### `workerEntryPoint`
+
+
+**Type:** `{path: string | URL, namedExports: string[]}`
+**Default:** `{ path: '@astrojs/cloudflare/entrypoints/server.js', namedExports: [] }`
+
+
+
+
+A configuration object to specify the [workerEntryPoint](https://developers.cloudflare.com/workers/runtime-apis/bindings/service-bindings/rpc/) for your Cloudflare Worker when you use the `astro build` command.
+
+It allows you to optionally specify both a custom file `path` and `namedExports`:
+
+```js title="astro.config.mjs"
+import cloudflare from '@astrojs/cloudflare';
+import { defineConfig } from 'astro/config';
+
+export default defineConfig({
+ adapter: cloudflare({
+ workerEntryPoint: {
+ path: 'src/worker.ts',
+ namedExports: ['MyDurableObject']
+ }
+ }),
+});
+```
+
+#### `workerEntryPoint.path`
+
+
+
+**Type:** `string`
+**Default:** `@astrojs/cloudflare/entrypoints/server.js`
+
+
+
+The path to the entry file. This should be a relative path from the root of your Astro project.
+
+By default, the adapter uses a generic entry file, which only supports the `fetch` handler.
+
+To support other [Cloudflare invocation handlers](https://developers.cloudflare.com/workers/observability/logs/workers-logs/#invocation-logs), you can create a custom file to use as the entry point. This is useful if you want to use features that require other handlers (e.g. Durable Objects, Cloudflare Queues, Scheduled Invocations).
+
+#### `workerEntryPoint.namedExports`
+
+
+
+**Type:** `[]`
+**Default:** `['default']`
+
+
+
+An array of named exports to use for the entry file.
+
+Provide any additional defined named exports of your [custom entry file](#creating-a-custom-cloudflare-worker-entry-file) (e.g. `DurableObjects`). If not provided, only default exports will be included.
+
+#### Creating a custom Cloudflare Worker entry file
+
+The custom entry file must export the `createExports()` function with a `default` export including all the handlers you need.
+
+The following example entry file registers a Durable Object and a queue handler:
+
+```ts title="src/worker.ts"
+import type { SSRManifest } from 'astro';
+
+import { App } from 'astro/app';
+import { handle } from '@astrojs/cloudflare/handler'
+import { DurableObject } from 'cloudflare:workers';
+
+class MyDurableObject extends DurableObject {
+ constructor(ctx: DurableObjectState, env: Env) {
+ super(ctx, env)
+ }
+}
+
+export function createExports(manifest: SSRManifest) {
+ const app = new App(manifest);
+ return {
+ default: {
+ async fetch(request, env, ctx) {
+ await env.MY_QUEUE.send("log");
+ return handle(manifest, app, request, env, ctx);
+ },
+ async queue(batch, _env) {
+ let messages = JSON.stringify(batch.messages);
+ console.log(`consumed from our queue: ${messages}`);
+ }
+ } satisfies ExportedHandler,
+ MyDurableObject: MyDurableObject,
+ }
+}
+```
+
## Cloudflare runtime
### Usage
diff --git a/src/content/docs/en/reference/configuration-reference.mdx b/src/content/docs/en/reference/configuration-reference.mdx
index 70098480f890d..30d842068da64 100644
--- a/src/content/docs/en/reference/configuration-reference.mdx
+++ b/src/content/docs/en/reference/configuration-reference.mdx
@@ -1133,65 +1133,78 @@ You can use wildcards to define the permitted `hostname` and `pathname` values a
- End with '/**' to allow all sub-routes ('startsWith').
- End with '/*' to allow only one level of sub-route.
-### image.experimentalLayout
+### image.responsiveStyles
+
+
+
+**Type:** `boolean`
+**Default:** `false`
+
+
+
+Whether to automatically add global styles for responsive images. You should enable this option unless you are styling the images yourself.
+
+This option is only used when `layout` is set to `constrained`, `full-width`, or `fixed` using the configuration or the `layout` prop on the image component.
+
+See [the Images guide](/en/guides/images/#responsive-image-styles) for more information.
+
+
+### image.layout
**Type:** `ImageLayout`
-**Default:** `undefined`
+**Default:** `undefined`
+
The default layout type for responsive images. Can be overridden by the `layout` prop on the image component.
-Requires the `experimental.responsiveImages` flag to be enabled.
- `constrained` - The image will scale to fit the container, maintaining its aspect ratio, but will not exceed the specified dimensions.
- `fixed` - The image will maintain its original dimensions.
- `full-width` - The image will scale to fit the container, maintaining its aspect ratio.
-### image.experimentalObjectFit
+See [the `layout` component property](/en/reference/modules/astro-assets/#layout) for more details.
+
+### image.objectFit
**Type:** `ImageFit`
-**Default:** `"cover"`
+**Default:** `"cover"`
+
-The default object-fit value for responsive images. Can be overridden by the `fit` prop on the image component.
-Requires the `experimental.responsiveImages` flag to be enabled.
+The [`object-fit` CSS property value](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) for responsive images. Can be overridden by the `fit` prop on the image component.
+Requires a value for `layout` to be set.
+
+See [the `fit` component property](/en/reference/modules/astro-assets/#fit) for more details.
-### image.experimentalObjectPosition
+### image.objectPosition
**Type:** `string`
-**Default:** `"center"`
+**Default:** `"center"`
+
-The default object-position value for responsive images. Can be overridden by the `position` prop on the image component.
-Requires the `experimental.responsiveImages` flag to be enabled.
+The default [`object-position` CSS property value](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) for responsive images. Can be overridden by the `position` prop on an individual image component. Requires a value for `layout` to be set.
+
+See [the `position` component property](/en/reference/modules/astro-assets/#position) for more details.
-### image.experimentalBreakpoints
+### image.breakpoints
**Type:** `Array`
-**Default:** `[640, 750, 828, 1080, 1280, 1668, 2048, 2560] | [640, 750, 828, 960, 1080, 1280, 1668, 1920, 2048, 2560, 3200, 3840, 4480, 5120, 6016]`
+**Default:** `[640, 750, 828, 1080, 1280, 1668, 2048, 2560] | [640, 750, 828, 960, 1080, 1280, 1668, 1920, 2048, 2560, 3200, 3840, 4480, 5120, 6016]`
+
-The breakpoints used to generate responsive images. Requires the `experimental.responsiveImages` flag to be enabled. The full list is not normally used,
+The breakpoints used to generate responsive images. Requires a value for `layout` to be set. The full list is not normally used,
but is filtered according to the source and output size. The defaults used depend on whether a local or remote image service is used. For remote services
the more comprehensive list is used, because only the required sizes are generated. For local services, the list is shorter to reduce the number of images generated.
-### image.experimentalDefaultStyles
-
-
-
-**Type:** `boolean`
-**Default:** `true`
-
-
-Whether to automatically add global styles to ensure that experimental images resize correctly. This is enabled by default, but can be disabled if you want to manage the styles yourself.
-This option is only used when the `experimental.responsiveImages` flag is enabled.
-
## Markdown Options
diff --git a/src/content/docs/en/reference/error-reference.mdx b/src/content/docs/en/reference/error-reference.mdx
index 61cebf144e16c..4c00307257b25 100644
--- a/src/content/docs/en/reference/error-reference.mdx
+++ b/src/content/docs/en/reference/error-reference.mdx
@@ -126,6 +126,7 @@ The following reference is a complete list of the errors you may encounter while
- [**InvalidContentEntryDataError**](/en/reference/errors/invalid-content-entry-data-error/) Content entry data does not match schema.
- [**ContentLoaderReturnsInvalidId**](/en/reference/errors/content-loader-returns-invalid-id/) Content loader returned an entry with an invalid `id`.
- [**ContentEntryDataError**](/en/reference/errors/content-entry-data-error/) Content entry data does not match schema.
+- [**LiveContentConfigError**](/en/reference/errors/live-content-config-error/) Error in live content config.
- [**ContentLoaderInvalidDataError**](/en/reference/errors/content-loader-invalid-data-error/) Content entry is missing an ID
- [**InvalidContentEntrySlugError**](/en/reference/errors/invalid-content-entry-slug-error/) Invalid content entry slug.
- [**ContentSchemaContainsSlugError**](/en/reference/errors/content-schema-contains-slug-error/) Content Schema should not contain `slug`.
diff --git a/src/content/docs/en/reference/errors/live-content-config-error.mdx b/src/content/docs/en/reference/errors/live-content-config-error.mdx
new file mode 100644
index 0000000000000..4e47e136fadb0
--- /dev/null
+++ b/src/content/docs/en/reference/errors/live-content-config-error.mdx
@@ -0,0 +1,25 @@
+---
+# NOTE: This file is auto-generated from 'scripts/error-docgen.mjs'
+# Do not make edits to it directly, they will be overwritten.
+# Instead, change this file: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
+# Translators, please remove this note and the component.
+
+title: Error in live content config.
+i18nReady: true
+githubURL: https://github.com/withastro/astro/blob/main/packages/astro/src/core/errors/errors-data.ts
+---
+import DontEditWarning from '~/components/DontEditWarning.astro'
+
+
+
+
+> **Example error message:**
+The schema cannot be a function for live collections. Please use a schema object instead. Check your collection definitions in your live content config file.
+
+## What went wrong?
+Error in live content config.
+
+**See Also:**
+- [Experimental live content](https://astro.build/en/reference/experimental-flags/live-content-collections/)
+
+
diff --git a/src/content/docs/en/reference/experimental-flags/live-content-collections.mdx b/src/content/docs/en/reference/experimental-flags/live-content-collections.mdx
new file mode 100644
index 0000000000000..fb638c472a08b
--- /dev/null
+++ b/src/content/docs/en/reference/experimental-flags/live-content-collections.mdx
@@ -0,0 +1,611 @@
+---
+title: Experimental live content collections
+sidebar:
+ label: Live content collections
+i18nReady: true
+---
+
+import Since from '~/components/Since.astro';
+
+
+
+**Type:** `boolean`
+**Default:** `false`
+
+
+
+
+Enables support for live content collections in your project.
+
+Live content collections are a new type of [content collection](/en/guides/content-collections/) that fetch their data at runtime rather than build time. This allows you to access frequently updated data from CMSs, APIs, databases, or other sources using a unified API, without needing to rebuild your site when the data changes.
+
+## Basic usage
+
+To enable the feature, add the `experimental.liveContentCollections` flag to your `astro.config.mjs` file:
+
+```js title="astro.config.mjs"
+{
+ experimental: {
+ liveContentCollections: true,
+ },
+}
+```
+
+Then create a new `src/live.config.ts` file (alongside your `src/content.config.ts` if you have one) to define your live collections with a [live loader](#creating-a-live-loader) and optionally a [schema](#using-zod-schemas) using the new `defineLiveCollection()` function from the `astro:content` module.
+
+```ts title="src/live.config.ts"
+import { defineLiveCollection } from 'astro:content';
+import { storeLoader } from '@mystore/astro-loader';
+
+const products = defineLiveCollection({
+ type: 'live',
+ loader: storeLoader({
+ apiKey: process.env.STORE_API_KEY,
+ endpoint: 'https://api.mystore.com/v1',
+ }),
+});
+
+export const collections = { products };
+```
+
+You can then use the dedicated `getLiveCollection()` and `getLiveEntry()` functions to access your live data:
+
+```astro
+---
+import { getLiveCollection, getLiveEntry } from 'astro:content';
+
+// Get all products
+const { entries: allProducts, error } = await getLiveCollection('products');
+if (error) {
+ // Handle error appropriately
+ console.error(error.message);
+}
+
+// Get products with a filter (if supported by your loader)
+const { entries: electronics } = await getLiveCollection('products', { category: 'electronics' });
+
+// Get a single product by ID (string syntax)
+const { entry: product, error: productError } = await getLiveEntry('products', Astro.params.id);
+if (productError) {
+ return Astro.redirect('/404');
+}
+
+// Get a single product with a custom query (if supported by your loader) using a filter object
+const { entry: productBySlug } = await getLiveEntry('products', { slug: Astro.params.slug });
+---
+```
+
+## When to use live content collections
+
+Live content collections are designed for data that changes frequently and needs to be up-to-date when a page is requested. Consider using them when:
+
+- **You need real-time information** (e.g. user-specific data, current stock levels)
+- **You want to avoid constant rebuilds** for content that changes often
+- **Your data updates frequently** (e.g. up-to-the-minute product inventory, prices, availability)
+- **You need to pass dynamic filters** to your data source based on user input or request parameters
+- **You're building preview functionality** for a CMS where editors need to see draft content immediately
+
+In contrast, use build-time content collections when:
+
+- **Performance is critical** and you want to pre-render data at build time
+- **Your data is relatively static** (e.g., blog posts, documentation, product descriptions)
+- **You want to benefit from build-time optimization** and caching
+- **You need to process MDX** or perform image optimization
+- **Your data can be fetched once and reused** across multiple builds
+
+See the [limitations of experimental live collections](#live-collection-limitations) and [key differences from build-time collections](#differences-from-build-time-collections) for more details on choosing between live and preloaded collections.
+
+## Using live collections
+
+You can [create your own live loaders](#creating-a-live-loader) for your data source, or you can use community loaders distributed as npm packages. Here's how you could use example CMS and e-commerce loaders:
+
+```ts title="src/live.config.ts"
+import { defineLiveCollection } from 'astro:content';
+import { cmsLoader } from '@example/cms-astro-loader';
+import { productLoader } from '@example/store-astro-loader';
+
+const articles = defineLiveCollection({
+ type: 'live',
+ loader: cmsLoader({
+ apiKey: process.env.CMS_API_KEY,
+ contentType: 'article',
+ }),
+});
+
+const products = defineLiveCollection({
+ type: 'live',
+ loader: productLoader({
+ apiKey: process.env.STORE_API_KEY,
+ }),
+});
+
+export const collections = { articles, authors };
+```
+
+You can then get content from both loaders with a unified API:
+
+```astro
+---
+import { getLiveCollection, getLiveEntry } from 'astro:content';
+
+// Use loader-specific filters
+const { entries: draftArticles } = await getLiveCollection('articles', {
+ status: 'draft',
+ author: 'john-doe',
+});
+
+// Get a specific product by ID
+const { entry: product } = await getLiveEntry('products', Astro.params.slug);
+---
+```
+
+### Error handling
+
+Live loaders can fail due to network issues, API errors, or validation problems. The API is designed to make error handling explicit.
+
+When you call `getLiveCollection()` or `getLiveEntry()`, the error will be one of:
+
+- The error type defined by the loader (if it returned an error)
+- A `LiveEntryNotFoundError` if the entry was not found
+- A `LiveCollectionValidationError` if the collection data does not match the expected schema
+- A `LiveCollectionCacheHintError` if the cache hint is invalid
+- A `LiveCollectionError` for other errors, such as uncaught errors thrown in the loader
+
+These errors have a static `is()` method that you can use to check the type of error at runtime:
+
+```astro "LiveEntryNotFoundError.is(error)"
+---
+import { getLiveEntry, LiveEntryNotFoundError } from 'astro:content';
+const { entry, error } = await getLiveEntry('products', Astro.params.id);
+if (error) {
+ if (LiveEntryNotFoundError.is(error)) {
+ console.error(`Product not found: ${error.message}`);
+ Astro.response.status = 404;
+ } else {
+ console.error(`Error loading product: ${error.message}`);
+ return Astro.redirect('/500');
+ }
+}
+---
+```
+
+## Creating a live loader
+
+A live loader is an object with two methods: `loadCollection()` and `loadEntry()`. These methods should handle errors gracefully and return either data or an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object.
+
+The standard pattern is to export a function that returns this loader object, allowing you to pass configuration options like API keys or endpoints.
+
+Here's a basic example:
+
+```ts title="myloader.ts"
+import type { LiveLoader } from 'astro/loaders';
+import { fetchFromCMS } from './cms-client.js';
+
+interface Article {
+ id: string;
+ title: string;
+ content: string;
+ author: string;
+}
+
+export function articleLoader(config: { apiKey: string }): LiveLoader {
+ return {
+ name: 'article-loader',
+ loadCollection: async ({ filter }) => {
+ try {
+ const articles = await fetchFromCMS({
+ apiKey: config.apiKey,
+ type: 'article',
+ filter,
+ });
+
+ return {
+ entries: articles.map((article) => ({
+ id: article.id,
+ data: article,
+ })),
+ };
+ } catch (error) {
+ return {
+ error: new Error(`Failed to load articles: ${error.message}`),
+ };
+ }
+ },
+ loadEntry: async ({ filter }) => {
+ try {
+ // filter will be { id: "some-id" } when called with a string
+ const article = await fetchFromCMS({
+ apiKey: config.apiKey,
+ type: 'article',
+ id: filter.id,
+ });
+
+ if (!article) {
+ return {
+ error: new Error('Article not found'),
+ };
+ }
+
+ return {
+ id: article.id,
+ data: article,
+ };
+ } catch (error) {
+ return {
+ error: new Error(`Failed to load article: ${error.message}`),
+ };
+ }
+ },
+ };
+}
+```
+
+### Rendering content
+
+A loader can add support for directly rendered content by returning [a `rendered` property](/en/reference/content-loader-reference/#rendered) in the entry. This allows you to use [the `render()` function and ` ` component](/en/guides/content-collections/#rendering-body-content) to render the content directly in your pages.
+If the loader does not return a `rendered` property for an entry, the ` ` component will render nothing.
+
+```ts title="myloader.ts" {16-19}
+// ...
+export function articleLoader(config: { apiKey: string }): LiveLoader {
+ return {
+ name: 'article-loader',
+ loadEntry: async ({ filter }) => {
+ try {
+ const article = await fetchFromCMS({
+ apiKey: config.apiKey,
+ type: 'article',
+ id: filter.id,
+ });
+
+ return {
+ id: article.id,
+ data: article,
+ rendered: {
+ // Assuming the CMS returns HTML content
+ html: article.htmlContent,
+ },
+ };
+ } catch (error) {
+ return {
+ error: new Error(`Failed to load article: ${error.message}`),
+ };
+ }
+ },
+ // ...
+ };
+}
+```
+
+You can then render both content and metadata from live collection entries in pages using the same method as built-time collections. You also have access to any [error returned by the live loader](#error-handling-in-loaders), for example, to rewrite to a 404 page when content cannot be displayed:
+
+```astro "render(entry)" " "
+---
+import { getLiveEntry, render } from 'astro:content';
+const { entry, error } = await getLiveEntry('articles', Astro.params.id);
+if (error) {
+ return Astro.rewrite('/404');
+}
+
+const { Content } = await render(entry);
+---
+
+{entry.data.title}
+
+```
+
+### Error handling in loaders
+
+Loaders should handle all errors and return an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) subclass for errors. You can create custom error types and use them for more specific error handling if needed. If an error is thrown in the loader, it will be caught and returned, wrapped in a `LiveCollectionError`. You can also create [custom error types](#custom-error-types) for proper typing.
+
+Astro will generate some errors itself, depending on the response from the loader:
+
+- If `loadEntry` returns `undefined`, Astro will return a `LiveEntryNotFoundError` to the user.
+- If a schema is defined for the collection and the data does not match the schema, Astro will return a `LiveCollectionValidationError`.
+- If the loader returns an invalid cache hint, Astro will return a `LiveCollectionCacheHintError`. The `cacheHint` field is optional, so if you do not have valid data to return, you can simply omit it.
+
+```ts title="my-loader.ts" {6-8}
+import type { LiveLoader } from 'astro/loaders';
+import { MyLoaderError } from './errors.js';
+
+export function myLoader(config): LiveLoader {
+ return {
+ name: 'my-loader',
+ loadCollection: async ({ filter }) => {
+ // Return your custom error type
+ return {
+ error: new MyLoaderError('Failed to load', 'LOAD_ERROR'),
+ };
+ },
+ // ...
+ };
+}
+```
+
+### Distributing your loader
+
+Loaders can be defined in your site or as a separate npm package. If you want to share your loader with the community, you can [publish it to NPM with the `astro-component` and `astro-loader` keywords](/en/reference/publish-to-npm/#packagejson-data).
+
+The loader should export a function that returns the `LiveLoader` object, allowing users to configure it with their own settings.
+
+## Type safety
+
+Like regular content collections, live collections can be typed to ensure type safety in your data. [Using Zod schemas](#using-zod-schemas) is supported, but not required to define types for live collections. Unlike preloaded collections defined at build time, live loaders can instead choose to pass generic types to the `LiveLoader` interface.
+You can define the types for your collection and entry data, as well as custom filter types for querying, and custom error types for error handling.
+
+### Type-safe data
+
+Live loaders can define types for the data they return. This allows TypeScript to provide type checking and autocompletion when working with the data in your components.
+
+```ts title="store-loader.ts" "LiveLoader" "type Product"
+import type { LiveLoader } from 'astro/loaders';
+import { fetchProduct, fetchCategory, type Product } from './store-client';
+
+export function storeLoader(): LiveLoader {
+ // ...
+}
+```
+
+When you use `getLiveCollection()` or `getLiveEntry()`, TypeScript will infer the types based on the loader's definition:
+
+```astro
+---
+import { getLiveEntry } from 'astro:content';
+const { entry: product } = await getLiveEntry('products', '123');
+// TypeScript knows product.data is of type Product
+console.log(product?.data.name);
+---
+```
+
+### Type-safe filters
+
+Live loaders can define custom filter types for both `getLiveCollection()` and `getLiveEntry()`. This enables type-safe querying that matches your API's capabilities, making it easier for users to discover available filters and ensure they are used correctly. If you include JSDoc comments in your filter types, the user will see these in their IDE as hints when using the loader.
+
+```ts title="store-loader.ts" "EntryFilter, CollectionFilter" {6,8}
+import type { LiveLoader } from 'astro/loaders';
+import { fetchProduct, fetchCategory, type Product } from './store-client';
+
+interface CollectionFilter {
+ category?: string;
+ /** Minimum price to filter products */
+ minPrice?: number;
+ /** Maximum price to filter products */
+ maxPrice?: number;
+}
+
+interface EntryFilter {
+ /** Alias for `sku` */
+ id?: string;
+ slug?: string;
+ sku?: string;
+}
+
+export function productLoader(config: {
+ apiKey: string;
+ endpoint: string;
+}): LiveLoader {
+ return {
+ name: 'product-loader',
+ loadCollection: async ({ filter }) => {
+ // filter is typed as CollectionFilter
+ const data = await fetchCategory({
+ apiKey: config.apiKey,
+ category: filter?.category ?? 'all',
+ minPrice: filter?.minPrice,
+ maxPrice: filter?.maxPrice,
+ });
+
+ return {
+ entries: data.products.map((product) => ({
+ id: product.sku,
+ data: product,
+ })),
+ };
+ },
+ loadEntry: async ({ filter }) => {
+ // filter is typed as EntryFilter | { id: string }
+ const product = await fetchProduct({
+ apiKey: config.apiKey,
+ slug: filter.slug,
+ sku: filter.sku || filter.id,
+ });
+ if (!product) {
+ return {
+ error: new Error('Product not found'),
+ };
+ }
+ return {
+ id: product.sku,
+ entry: product,
+ };
+ },
+ };
+}
+```
+
+### Custom error types
+
+You can create custom error types for [errors returned by your loader](#error-handling-in-loaders) and pass them as a generic to get proper typing:
+
+```ts title="my-loader.ts"
+class MyLoaderError extends Error {
+ constructor(
+ message: string,
+ public code?: string
+ ) {
+ super(message);
+ this.name = 'MyLoaderError';
+ }
+}
+
+export function myLoader(config): LiveLoader {
+ return {
+ name: 'my-loader',
+ loadCollection: async ({ filter }) => {
+ // Return your custom error type
+ return {
+ error: new MyLoaderError('Failed to load', 'LOAD_ERROR'),
+ };
+ },
+ // ...
+ };
+}
+```
+
+When you use `getLiveCollection()` or `getLiveEntry()`, TypeScript will infer the custom error type, allowing you to handle it appropriately:
+
+```astro
+---
+import { getLiveEntry } from 'astro:content';
+const { entry, error } = await getLiveEntry('products', '123');
+if (error) {
+ if (error.name === 'MyLoaderError') {
+ console.error(`Loader error: ${error.message} (code: ${error.code})`);
+ } else {
+ console.error(`Unexpected error: ${error.message}`);
+ }
+ return Astro.rewrite('/500');
+}
+---
+```
+
+## Using Zod schemas
+
+Just like with build-time collections, you can use [Zod schemas](/en/guides/content-collections/#defining-the-collection-schema) with live collections to validate and transform data at runtime. When you define a schema, it takes precedence over [the loader's types](#type-safe-data) when you query the collection:
+
+```ts title="src/live.config.ts"
+import { z, defineLiveCollection } from 'astro:content';
+import { apiLoader } from './loaders/api-loader';
+
+const products = defineLiveCollection({
+ type: 'live',
+ loader: apiLoader({ endpoint: process.env.API_URL }),
+ schema: z
+ .object({
+ id: z.string(),
+ name: z.string(),
+ price: z.number(),
+ // Transform the API's category format
+ category: z.string().transform((str) => str.toLowerCase().replace(/\s+/g, '-')),
+ // Coerce the date to a Date object
+ createdAt: z.coerce.date(),
+ })
+ .transform((data) => ({
+ ...data,
+ // Add a formatted price field
+ displayPrice: `$${data.price.toFixed(2)}`,
+ })),
+});
+
+export const collections = { products };
+```
+
+When using Zod schemas, validation errors are automatically caught and returned as `AstroError` objects:
+
+```astro
+---
+import { getLiveEntry, LiveCollectionValidationError } from 'astro:content';
+
+const { entry, error } = await getLiveEntry('products', '123');
+
+// You can handle validation errors specifically
+if (LiveCollectionValidationError.is(error)) {
+ console.error(error.message);
+ return Astro.rewrite('/500');
+}
+
+// TypeScript knows entry.data matches your Zod schema, not the loader's type
+console.log(entry?.data.displayPrice); // e.g., "$29.99"
+---
+```
+
+## Cache hints
+
+Live loaders can provide cache hints to help with response caching. You can use this data to send HTTP cache headers or otherwise inform your caching strategy.
+
+```ts title="my-loader.ts"
+export function myLoader(config): LiveLoader {
+ return {
+ name: 'cached-loader',
+ loadCollection: async ({ filter }) => {
+ // ... fetch data
+ return {
+ entries: data.map((item) => ({
+ id: item.id,
+ data: item,
+ // You can optionally provide cache hints for each entry
+ // These are merged with the collection's cache hint
+ cacheHint: {
+ tags: [`product-${item.id}`, `category-${item.category}`],
+ },
+ })),
+ cacheHint: {
+ tags: ['products'],
+ maxAge: 300, // 5 minutes
+ },
+ };
+ },
+ loadEntry: async ({ filter }) => {
+ // ... fetch single item
+ return {
+ id: item.id,
+ data: item,
+ cacheHint: {
+ tags: [`product-${item.id}`, `category-${item.category}`],
+ maxAge: 3600, // 1 hour
+ },
+ };
+ },
+ };
+}
+```
+
+You can then use these hints in your pages:
+
+```astro
+---
+import { getLiveEntry } from 'astro:content';
+
+const { entry, error, cacheHint } = await getLiveEntry('products', Astro.params.id);
+
+if (error) {
+ return Astro.redirect('/404');
+}
+
+// Apply cache hints to response headers
+if (cacheHint) {
+ Astro.response.headers.set('Cache-Tag', cacheHint.tags.join(','));
+ Astro.response.headers.set('Cache-Control', `s-maxage=${cacheHint.maxAge}`);
+}
+---
+
+{entry.data.name}
+{entry.data.description}
+```
+
+:::note
+Cache hints only provide values that can be used in other parts of your project and do not automatically cause the response to be cached by Astro. You can use them to create your own caching strategy, such as setting HTTP headers or using a CDN.
+:::
+
+## Live collection limitations
+
+Live content collections have some limitations compared to build-time collections:
+
+- **No MDX support**: MDX cannot be rendered at runtime
+- **No image optimization**: Images cannot be processed at runtime
+- **Performance considerations**: Data is fetched on each request (unless cached)
+- **No data store persistence**: Data is not saved to the content layer data store
+
+## Differences from build-time collections
+
+Live collections use a different API than current preloaded content collections. Key differences include:
+
+1. **Execution time**: Runs at request time instead of build time
+1. **Configuration file**: Use `src/live.config.ts` instead of `src/content.config.ts`
+1. **Collection definition**: Use `defineLiveCollection()` instead of `defineCollection()`
+1. **Collection type**: Set `type: "live"` in collection definition
+1. **Loader API**: Implement `loadCollection` and `loadEntry` methods instead of the `load` method
+1. **Data return**: Return data directly instead of storing in the data store
+1. **User-facing functions**: Use `getLiveCollection`/`getLiveEntry` instead of `getCollection`/`getEntry`
+
+For a complete overview and to give feedback on this experimental API, see the [Live Content collections RFC](https://github.com/withastro/roadmap/blob/feat/live-loaders/proposals/0055-live-content-loaders.md).
diff --git a/src/content/docs/en/reference/experimental-flags/responsive-images.mdx b/src/content/docs/en/reference/experimental-flags/responsive-images.mdx
deleted file mode 100644
index 1aefa7a9b4851..0000000000000
--- a/src/content/docs/en/reference/experimental-flags/responsive-images.mdx
+++ /dev/null
@@ -1,178 +0,0 @@
----
-title: Experimental responsive images
-sidebar:
- label: Responsive images
-i18nReady: true
----
-
-import Since from '~/components/Since.astro'
-
-
-
-**Type:** `boolean`
-**Default:** `false`
-
-
-
-Enables support for automatic responsive images in your project.
-
-The term [responsive images](https://developer.mozilla.org/en-US/docs/Web/HTML/Guides/Responsive_images) refers images that work well on different devices. This particularly applies to images that resize to fit their container, and that can be served in different sizes depending on the device's screen size and resolution.
-
-There are a number of additional properties that can be set to control how the image is displayed, but these can be complicated to handle manually. Incorrect handling of these properties can lead to images that are slow to download or that are not displayed correctly. This is one of the most common causes of poor Core Web Vitals and Lighthouse performance scores.
-
-When this flag is enabled, Astro can automatically generate the required `srcset` and `sizes` values for images, and apply the correct styles to ensure they resize correctly. This behavior can be configured globally or on a per-image basis.
-
-To enable the feature, first add the `responsiveImages` flag to your `astro.config.mjs` file:
-
-```js title="astro.config.mjs"
-{
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-Enabling this flag will not change anything by default, but responsive images can then be configured by setting the [image layout](#image-layout) either globally or per image.
-
-To do this, you have access to additional [`image` configuration settings](#configuration-settings) for controlling the default behavior of all images processed and optimized by Astro:
-
-- Local and remote images using [the Markdown `![]()` syntax](/en/guides/images/#images-in-markdown-files).
-- The [` `](/en/guides/images/#display-optimized-images-with-the-image--component) and [` `](/en/guides/images/#create-responsive-images-with-the-picture--component) components.
-
-Additionally, Astro's image components can receive [responsive image props](#responsive-image-properties) to override these defaults on a per-image basis.
-
-Images in your `public/` folder are never optimized, and responsive images are not supported.
-
-:::note
-Enabling responsive images will generate additional image sizes for all affected images. For prerendered pages this happens during the build so may increase the build time of your project, especially if you have a large number of images.
-
-For pages rendered on-demand the images are generated as-needed, so this has no impact on build times but may increase the number of transformations performed. Depending on your image service this may incur additional costs.
-:::
-
-## Image layout
-
-In order to generate the correct `srcset` and `sizes` attributes, the ` ` and ` ` components need to know how the image should resize when its container changes size. This is done by setting the `layout` prop, or `image.experimentalLayout` default. The supported values are:
-
-- `constrained` - The image will scale down to fit the container, maintaining its aspect ratio, but will not scale up beyond the specified `width` and `height`, or the image's original dimensions. Use this if you want the image to display at the requested size where possible, but shrink to fit smaller screens. This matches the default behavior for images when using Tailwind. If you're not sure, this is probably the layout you should choose.
-- `full-width` - The image will scale to fit the width of the container, maintaining its aspect ratio. Use this for hero images or other images that should take up the full width of the page.
-- `fixed` - The image will maintain the requested dimensions and not resize. It will generate a `srcset` to support high density displays, but not for different screen sizes. Use this if the image will not resize, for example icons or logos smaller than any screen width, or other images in a fixed-width container.
-- `none` - The image will not be responsive. No `srcset` or `sizes` will be automatically generated, and no styles will be applied. This is useful if you have enabled a default layout, but want to disable it for a specific image.
-
-The chosen `layout` will be used to generate the correct `srcset` and `sizes` attributes for the image, and will define the default styles applied to that ` ` tag.
-
-## Configuration settings
-
-Set [`image.experimentalLayout`](/en/reference/configuration-reference/#imageexperimentallayout) with a default value to enable responsive images throughout your project.
-
-If this value is not configured, you can still pass a `layout` prop to any ` ` or ` ` component to create a responsive image. However, Markdown images will not be responsive.
-
-Optionally, you can configure [`image.experimentalObjectFit`](/en/reference/configuration-reference/#imageexperimentalobjectfit) and [`image.experimentalObjectPosition`](/en/reference/configuration-reference/#imageexperimentalobjectposition) which will apply to all processed images by default.
-
-Each of these settings can be overridden on any individual ` ` or ` ` component with a prop, but Markdown images will always use the default settings.
-
-```js title="astro.config.mjs"
-{
- image: {
- // Used for all Markdown images; not configurable per-image
- // Used for all ` ` and ` ` components unless overridden with a prop
- experimentalLayout: 'constrained',
- },
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-## Responsive image properties
-
-These are additional properties available to the ` ` and ` ` components when responsive images are enabled:
-
-- `layout`: The [layout type](#image-layout) for the image. Can be `constrained`, `fixed`, `full-width`, or `none`. If set to `none`, responsive behavior is disabled for this image and all other options are ignored. Defaults to `none`, or the value of [`image.experimentalLayout`](/en/reference/configuration-reference/#imageexperimentallayout) if set.
-- `fit`: Defines how the image should be cropped if the aspect ratio is changed. Values match those of CSS `object-fit`. Defaults to `cover`, or the value of [`image.experimentalObjectFit`](/en/reference/configuration-reference/#imageexperimentalobjectfit) if set.
-- `position`: Defines the position of the image crop if the aspect ratio is changed. Values match those of CSS `object-position`. Defaults to `center`, or the value of [`image.experimentalObjectPosition`](/en/reference/configuration-reference/#imageexperimentalobjectposition) if set.
-- `priority`: If set, eagerly loads the image. Otherwise, images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`.
-
-The `widths` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type, and in most cases should not be set manually. The generated `sizes` attribute for `constrained` and `full-width` images
-is based on the assumption that the image is displayed at close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens) you may need to adjust the `sizes` attribute manually for best results.
-
-The `densities` attribute is not compatible with responsive images and will be ignored if set.
-
-For example, with `constrained` set as the default layout, you can override any individual image's `layout` property:
-
-```astro
----
-import { Image } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-
-```
-
-## Generated HTML output for responsive images
-
-When a layout is set, either by default or on an individual component, images have automatically generated `srcset` and `sizes` attributes based on the image's dimensions and the layout type. Images with `constrained` and `full-width` layouts will have styles applied to ensure they resize according to their container.
-
-```astro title=MyComponent.astro
----
-import { Image, Picture } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-```
-
-This ` ` component will generate the following HTML output:
-
-```html
-
-```
-
-## Default responsive image styles
-
-The responsive image component applies a small number of styles to ensure they resize correctly. The applied styles depend on the layout type, and are designed to give the best behavior for the generated `srcset` and `sizes` attributes:
-
-```css title="Responsive Image Styles"
-:where([data-astro-image]) {
- object-fit: var(--fit);
- object-position: var(--pos);
-}
-:where([data-astro-image='full-width']) {
- width: 100%;
-}
-:where([data-astro-image='constrained']) {
- max-width: 100%;
-}
-```
-
-### Overriding default styles
-
-The styles use the [`:where()` pseudo-class](https://developer.mozilla.org/en-US/docs/Web/CSS/:where), which has a [specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_cascade/Specificity) of 0, meaning that it is easy to override with your own styles. Any CSS selector will have a higher specificity than `:where()`, so you can easily override the styles by adding your own styles to target the image.
-
-You can override the `object-fit` and `object-position` styles on a per-image basis by setting the `fit` and `position` props on the ` ` or ` ` component.
-
-You can disable the default styles entirely by setting [`image.experimentalDefaultStyles`](/en/reference/configuration-reference/#imageexperimentaldefaultstyles) to `false` if you prefer to handle styling responsive images yourself.
-
-#### Tailwind 4
-
-Tailwind 4 is a special case, because it uses [cascade layers](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer), meaning the Tailwind rules are always lower specificity than rules that don't use layers. Astro supports browsers that do not support cascade layers, so it cannot use them for images. This means that [you should disable the default styles](/en/reference/configuration-reference/#imageexperimentaldefaultstyles) if you need to override them with Tailwind 4.
-
-For a complete overview, and to give feedback on this experimental API, see the [Responsive Images RFC](https://github.com/withastro/roadmap/blob/responsive-images/proposals/0053-responsive-images.md).
diff --git a/src/content/docs/en/reference/modules/astro-assets.mdx b/src/content/docs/en/reference/modules/astro-assets.mdx
index 4fc395c53da5e..728daa74bdefe 100644
--- a/src/content/docs/en/reference/modules/astro-assets.mdx
+++ b/src/content/docs/en/reference/modules/astro-assets.mdx
@@ -27,6 +27,10 @@ import {
### ` `
+The ` ` component optimizes and transforms images.
+
+This component can also be used to create [responsive images](#responsive-image-properties) that can adjust based on the size of their container or a device screen size and resolution.
+
```astro title="src/components/MyComponent.astro"
---
// import the Image component and the image
@@ -53,7 +57,7 @@ import myImage from "../assets/my_image.png"; // Image is 1600x900
#### Image properties
-The ` ` component accepts all properties accepted by the HTML ` ` tag in addition to the properties described below.
+The ` ` component accepts the following listed properties and [responsive image properties](#responsive-image-properties) in addition to all properties accepted by the HTML ` ` tag.
##### src (required)
@@ -122,6 +126,8 @@ If an image is merely decorative (i.e. doesn't contribute to the understanding o
These properties define the dimensions to use for the image.
+When a `layout` type is set, these are automatically generated based on the image's dimensions and in most cases should not be set manually.
+
When using images in their original aspect ratio, `width` and `height` are optional. These dimensions can be automatically inferred from image files located in `src/`. For remote images, add [the `inferSize` attribute set to `true`](#infersize) on the ` ` or ` ` component or use [`inferRemoteSize()` function](#inferremotesize).
However, both of these properties are required for images stored in your `public/` folder as Astro is unable to analyze these files.
@@ -136,6 +142,8 @@ However, both of these properties are required for images stored in your `public
A list of pixel densities to generate for the image.
+The `densities` attribute is not compatible with responsive images using a `layout` property and will be ignored if set.
+
If provided, this value will be used to generate a `srcset` attribute on the ` ` tag. Do not provide a value for `widths` when using this value.
Densities that are equal to widths larger than the original image will be ignored to avoid upscaling the image.
@@ -181,6 +189,8 @@ A list of widths to generate for the image.
If provided, this value will be used to generate a `srcset` attribute on the ` ` tag. A [`sizes` property](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/sizes) must also be provided.
+The `widths` and `sizes` attributes will be automatically generated for responsive images using a `layout` property. Providing these values is generally not needed, but can be used to override any automatically generated values.
+
Do not provide a value for `densities` when using this value. Only one of these two values can be used to generate a `srcset`.
Widths that are larger than the original image will be ignored to avoid upscaling the image.
@@ -222,6 +232,21 @@ import myImage from '../assets/my_image.png'; // Image is 1600x900
/>
```
+##### sizes
+
+
+
+**Type:** `string | undefined`
+
+
+
+Specifies the layout width of the image for each of a list of media conditions. Must be provided when specifying `widths`.
+
+The `widths` and `sizes` attributes will be automatically generated for responsive images using a `layout` property. Providing these values is generally not needed, but can be used to override any automatically generated values.
+
+The generated `sizes` attribute for `constrained` and `full-width` images is based on the assumption that the image is displayed close to the full width of the screen when the viewport is smaller than the image's width. If it is significantly different (e.g. if it's in a multi-column layout on small screens), you may need to adjust the `sizes` attribute manually for best results.
+
+
##### format
@@ -249,6 +274,7 @@ By default, the ` ` component will produce a `.webp` file.
**Type:** `boolean`
+**Default:** `false`
@@ -258,7 +284,7 @@ By default, this value is set to `false` and you must manually specify both dime
Add `inferSize` to the ` ` component (or `inferSize: true` to `getImage()`) to infer these values from the image content when fetched. This is helpful if you don't know the dimensions of the remote image, or if they might change:
-```astro mark="inferSize"
+```astro title="src/components/MyComponent.astro" "inferSize"
---
import { Image } from 'astro:assets';
---
@@ -267,11 +293,42 @@ import { Image } from 'astro:assets';
`inferSize` can fetch the dimensions of a [remote image from a domain that has not been authorized](/en/guides/images/#authorizing-remote-images), however the image itself will remain unprocessed.
+#### priority
+
+
+
+**Type:** `boolean`
+**Default:** `false`
+
+
+
+Allows you to automatically set the `loading`, `decoding`, and `fetchpriority` attributes to their optimal values for above-the-fold images.
+
+```astro title="src/components/MyComponent.astro" "priority"
+---
+import { Image } from 'astro:assets';
+import myImage from '../assets/my_image.png';
+---
+
+```
+
+When `priority: true` (or the shorthand syntax `priority`) is added to the ` ` or ` ` component, it will add the following attributes to instruct the browser to load the image immediately:
+
+```
+loading="eager"
+decoding="sync"
+fetchpriority="high"
+```
+
+These individual attributes can still be set manually if you need to customize them further.
+
### ` `
-Use the built-in ` ` Astro component to display a responsive image with multiple formats and/or sizes.
+The ` ` component generates an optimized image with multiple formats and/or sizes.
+
+This component can also be used to create [responsive images](#responsive-image-properties) that can adjust based on the size of their container or a device screen size and resolution.
```astro title="src/pages/index.astro"
---
@@ -301,7 +358,7 @@ import myImage from "../assets/my_image.png"; // Image is 1600x900
#### Picture properties
-` ` accepts all the properties of [the ` ` component](#image-properties), plus the following:
+` ` accepts all the properties of [the ` ` component](#image-properties), including [responsive image properties](#responsive-image-properties), plus the following:
##### `formats`
@@ -360,6 +417,137 @@ import myImage from "../my_image.png"; // Image is 1600x900
```
+### Responsive image properties
+
+Setting the [`layout`](#layout) property on an [` `](#image-) or [` `](#picture-) component creates a responsive image and enables additional property settings.
+
+```astro title=MyComponent.astro
+---
+import { Image } from 'astro:assets';
+import myImage from '../assets/my_image.png';
+---
+
+```
+
+ When a layout is set, `srcset` and `sizes` attributes are automatically generated based on the image's dimensions and the layout type. The previous ` ` component will generate the following HTML output:
+
+```html
+
+```
+The value for `layout` also defines the default styles applied to the ` ` tag to determine how the image should resize according to its container:
+
+```css title="Responsive Image Styles"
+:where([data-astro-image]) {
+ object-fit: var(--fit);
+ object-position: var(--pos);
+}
+:where([data-astro-image='full-width']) {
+ width: 100%;
+}
+:where([data-astro-image='constrained']) {
+ max-width: 100%;
+}
+```
+
+You can override the default `object-fit` and `object-position` styles by setting the [`fit`](#fit) and [`position`](#position) props on the ` ` or ` ` component.
+
+
+##### layout
+
+
+
+**Type:** `'constrained' | 'full-width' | 'fixed' | 'none'`
+**Default:** `image.layout | 'none'`
+
+
+
+Defines a [responsive image](#responsive-image-properties) and determines how the image should resize when its container changes size. Can be used to override the default configured value for [`image.layout`](/en/reference/configuration-reference/#imagelayout).
+
+- `constrained` - The image will scale down to fit the container, maintaining its aspect ratio, but will not scale up beyond the specified `width` and `height`, or the image's original dimensions.
+
+ Use this if you want the image to display at the requested size where possible, but shrink to fit smaller screens. This matches the default behavior for images when using Tailwind. If you're not sure, this is probably the layout you should choose.
+
+- `full-width` - The image will scale to fit the width of the container, maintaining its aspect ratio.
+
+ Use this for hero images or other images that should take up the full width of the page.
+
+- `fixed` - The image will maintain the requested dimensions and not resize. It will generate a `srcset` to support high density displays, but not for different screen sizes.
+
+ Use this if the image will not resize, for example icons or logos smaller than any screen width, or other images in a fixed-width container.
+
+- `none` - The image will not be responsive. No `srcset` or `sizes` will be automatically generated, and no styles will be applied.
+
+ This is useful if you have enabled a default layout, but want to disable it for a specific image.
+
+For example, with `constrained` set as the default layout, you can override any individual image's `layout` property:
+
+```astro title="src/components/MyComponent.astro"
+---
+import { Image } from 'astro:assets';
+import myImage from '../assets/my_image.png';
+---
+
+
+
+```
+
+##### fit
+
+
+
+**Type:** `'contain' | 'cover' | 'fill' | 'none' | 'scale-down'`
+**Default:** `image.objectFit | 'cover'`
+
+
+
+Enabled when the [`layout`](#layout) property is set or configured. Defines how a responsive image should be cropped if its aspect ratio is changed.
+
+Values match those of CSS `object-fit`. Defaults to `cover`, or the value of [`image.objectFit`](/en/reference/configuration-reference/#imageobjectfit) if set. Can be used to override the default `object-fit` styles.
+
+##### position
+
+
+
+**Type:** `string`
+**Default:** `image.objectPosition | 'center'`
+
+
+
+Enabled when the [`layout`](#layout) property is set or configured. Defines the position of the image crop for a responsive image if the aspect ratio is changed.
+
+Values match those of CSS `object-position`. Defaults to `center`, or the value of [`image.objectPosition`](/en/reference/configuration-reference/#imageobjectposition) if set. Can be used to override the default `object-position` styles.
+
+##### priority
+
+
+
+**Type:** `boolean`
+**Default:** `false`
+
+
+
+Enabled when the [`layout`](#layout) property is set or configured. If set, eagerly loads a responsive image. Otherwise, images will be lazy-loaded. Use this for your largest above-the-fold image. Defaults to `false`.
+
+
+
### `getImage()`
diff --git a/src/content/docs/fr/reference/experimental-flags/responsive-images.mdx b/src/content/docs/fr/reference/experimental-flags/responsive-images.mdx
deleted file mode 100644
index a3d7b764a441f..0000000000000
--- a/src/content/docs/fr/reference/experimental-flags/responsive-images.mdx
+++ /dev/null
@@ -1,177 +0,0 @@
----
-title: Images adaptatives (expérimental)
-sidebar:
- label: Images adaptatives
-i18nReady: true
----
-
-import Since from '~/components/Since.astro'
-
-
-
-**Type :** `boolean`
-**Par défaut :** `false`
-
-
-
-Active la prise en charge des images adaptatives automatiques dans votre projet.
-
-Le terme [images adaptatives](https://developer.mozilla.org/fr/docs/Web/HTML/Guides/Responsive_images) désigne les images qui fonctionnent bien sur différents appareils. Cela s'applique particulièrement aux images qui sont redimensionnées pour s'adapter à leur conteneur et qui peuvent être présentées dans différentes tailles en fonction de la taille et de la résolution de l'écran de l'appareil.
-
-Il existe un certain nombre de propriétés supplémentaires qui peuvent être définies pour contrôler la façon dont l'image est affichée, mais celles-ci peuvent être compliquées à gérer manuellement. Une mauvaise gestion de ces propriétés peut conduire à des images lentes à télécharger ou qui ne s'affichent pas correctement. Il s’agit de l’une des causes les plus courantes des mauvais scores de performances Core Web Vitals et Lighthouse.
-
-Lorsque cet indicateur est activé, Astro génère automatiquement les valeurs `srcset` et `sizes` requises pour les images, et applique les styles appropriés pour garantir un redimensionnement correct. Ce comportement peut être configuré globalement ou image par image.
-
-Pour activer la fonctionnalité, ajoutez d'abord l'option `responsiveImages` dans votre fichier `astro.config.mjs` :
-
-```js title="astro.config.mjs"
-{
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-L'activation de cette option ne changera rien par défaut, mais les images adaptatives peuvent ensuite être configurées en définissant la [mise en page de l'image](#mise-en-page-des-images) soit globalement, soit par image.
-
-Pour ce faire, vous avez accès à des [paramètres supplémentaires de configuration d'`image`](#paramètres-de-configuration) pour contrôler le comportement par défaut de toutes les images traitées et optimisées par Astro :
-
-- Les images locales et distantes utilisant [la syntaxe Markdown `![]()`](/fr/guides/images/#images-dans-les-fichiers-markdown).
-- Les composants [` `](/fr/guides/images/#afficher-des-images-optimisées-avec-le-composant-image-) et [` `](/fr/guides/images/#créez-des-images-adaptatives-avec-le-composant-picture-).
-
-De plus, les composants d'image d'Astro peuvent recevoir [des props d'images adaptatives](#propriétés-des-images-adaptatives) pour remplacer ces valeurs par défaut pour chaque image.
-
-Les images dans votre dossier `public/` ne sont jamais optimisées et les images adaptatives ne sont pas prises en charge.
-
-:::note
-L'activation des images adaptatives générera des tailles d'image supplémentaires pour toutes les images concernées. Pour les pages pré-rendues, cela se produit pendant la construction et peut donc augmenter le temps de construction de votre projet, surtout si vous avez un grand nombre d'images.
-
-Pour les pages rendues à la demande, les images sont générées selon les besoins. Cela n'a donc aucun impact sur les délais de création, mais peut augmenter le nombre de transformations effectuées. Selon votre service d'images, cela peut entraîner des coûts supplémentaires.
-:::
-
-## Mise en page des images
-
-Afin de générer les attributs `srcset` et `sizes` appropriés, les composants ` ` et ` ` doivent savoir comment l'image doit être redimensionnée lorsque son conteneur change de taille. Cela se fait en définissant la propriété `layout` ou la valeur par défaut avec `image.experimentalLayout`. Les valeurs prises en charge sont :
-
-- `constrained` - L'image sera réduite pour s'adapter au conteneur, en conservant ses proportions, mais ne s'agrandira pas au-delà de la largeur (`width`) et de la hauteur (`height`) spécifiées, ou des dimensions d'origine de l'image. Utilisez cette option si vous souhaitez que l'image s'affiche à la taille demandée, si possible, mais qu'elle soit réduite pour s'adapter aux écrans plus petits. Ce comportement correspond au comportement par défaut des images avec Tailwind. Si vous n’êtes pas sûr, c’est probablement la mise en page que vous devriez choisir.
-- `full-width` - L'image s'adaptera à la largeur du conteneur, tout en conservant ses proportions. Utilisez cette option pour les images de couverture ou les autres images qui doivent occuper toute la largeur de la page.
-- `fixed` - L'image conservera les dimensions demandées et ne sera pas redimensionnée. Un `srcset` sera généré pour prendre en charge les affichages haute densité, mais pas pour les différentes tailles d'écran. Utilisez cette option si l'image ne peut pas être redimensionnée, par exemple pour des icônes ou des logos plus petits que la largeur de l'écran, ou pour d'autres images dans un conteneur à largeur fixe.
-- `none` - L'image ne sera pas adaptative. Aucun `srcset` ou `sizes` ne sera automatiquement généré et aucun style ne sera appliqué. Ceci est utile si vous avez activé une mise en page par défaut, mais souhaitez la désactiver pour une image spécifique.
-
-La mise en page (`layout`) choisie sera utilisée pour générer les attributs `srcset` et `sizes` corrects pour l'image, et définira les styles par défaut appliqués à cette balise ` `.
-
-## Paramètres de configuration
-
-Définissez [`image.experimentalLayout`](/fr/reference/configuration-reference/#imageexperimentallayout) avec une valeur par défaut pour activer les images adaptatives dans tout votre projet.
-
-Si cette valeur n'est pas configurée, vous pouvez toujours transmettre une propriété `layout` à n'importe quel composant ` ` ou ` ` pour créer une image adaptative. Cependant, les images Markdown ne seront pas adaptatives.
-
-En option, vous pouvez configurer [`image.experimentalObjectFit`](/fr/reference/configuration-reference/#imageexperimentalobjectfit) et [`image.experimentalObjectPosition`](/fr/reference/configuration-reference/#imageexperimentalobjectposition) qui s'appliqueront à toutes les images traitées par défaut.
-
-Chacun de ces paramètres peut être remplacé sur n'importe quel composant individuel ` ` ou ` ` avec une propriété, mais les images Markdown utiliseront toujours les paramètres par défaut.
-
-```js title="astro.config.mjs"
-{
- image: {
- // Utilisé pour toutes les images Markdown ; non configurable par image
- // Utilisé pour tous les composants ` ` et ` ` sauf s'ils sont remplacés par une propriété
- experimentalLayout: 'constrained',
- },
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-## Propriétés des images adaptatives
-
-Voici les propriétés supplémentaires disponibles pour les composants ` ` et ` ` lorsque les images adaptatives sont activées :
-
-- `layout` : Le [type de mise en page](#mise-en-page-des-images) de l'image. Il peut s'agir de `constrained`, `fixed`, `full-width` ou `none`. Si défini sur `none`, le comportement réactif est désactivé pour cette image et toutes les autres options sont ignorées. La valeur par défaut est `none`, ou la valeur définie dans [`image.experimentalLayout`](/fr/reference/configuration-reference/#imageexperimentallayout).
-- `fit` : Définit comment l'image doit être recadrée si le ratio d'aspect est modifié. Les valeurs correspondent à celles de CSS `object-fit`. La valeur par défaut est `cover`, ou la valeur de [`image.experimentalObjectFit`](/fr/reference/configuration-reference/#imageexperimentalobjectfit) si elle est définie.
-- `position` : Définit la position du recadrage de l'image si le rapport hauteur/largeur est modifié. Les valeurs correspondent à celles de CSS `object-position`. La valeur par défaut est `center`, ou la valeur de [`image.experimentalObjectPosition`](/fr/reference/configuration-reference/#imageexperimentalobjectposition) si elle est définie.
-- `priority` : Si elle est définie, l'image est chargée avec empressement. Sinon, les images seront chargées paresseusement. Utilisez cette option pour votre plus grande image. La valeur par défaut est `false`.
-
-Les attributs `widths` et `sizes` sont automatiquement générés en fonction des dimensions de l'image et du type de mise en page, et dans la plupart des cas, ils ne doivent pas être définis manuellement. L'attribut `sizes` généré pour les images `constrained` et `full-width` (pleine largeur) est basé sur l'hypothèse que l'image est affichée à peu près sur toute la largeur de l'écran lorsque la fenêtre de visualisation est plus petite que la largeur de l'image. Si c'est significativement différent (par exemple, s'il s'agit d'une mise en page en plusieurs colonnes sur de petits écrans), vous devrez peut-être ajuster l'attribut `sizes` manuellement pour obtenir les meilleurs résultats.
-
-L'attribut `densities` n'est pas compatible avec les images adaptatives et sera ignoré s'il est défini.
-
-Par exemple, avec `constrained` défini comme mise en page par défaut, vous pouvez remplacer la propriété `layout` de n’importe quelle image individuelle :
-
-```astro
----
-import { Image } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-
-```
-
-## Sortie HTML générée pour les images adaptatives
-
-Lorsqu'une mise en page est définie, soit par défaut, soit sur un composant individuel, les images possèdent des attributs `srcset` et `sizes` automatiquement générés en fonction des dimensions de l'image et du type de mise en page. Les images avec des mises en page `constrained` et `full-width` auront des styles appliqués pour garantir qu'elles se redimensionnent en fonction de leur conteneur.
-
-```astro title=MyComponent.astro
----
-import { Image, Picture } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-```
-
-Ce composant ` ` générera le code HTML suivant :
-
-```html
-
-```
-
-## Styles d'images adaptatives par défaut
-
-Le composant d'images adaptatives applique un nombre limité de styles pour garantir qu'elles sont correctement redimensionnées. Les styles appliqués dépendent du type de mise en page et sont conçus pour optimiser le comportement des attributs `srcset` et `sizes` générés :
-
-```css title="Styles des images adaptatives"
-:where([data-astro-image]) {
- object-fit: var(--fit);
- object-position: var(--pos);
-}
-:where([data-astro-image='full-width']) {
- width: 100%;
-}
-:where([data-astro-image='constrained']) {
- max-width: 100%;
-}
-```
-
-### Remplacement des styles par défaut
-
-Les styles utilisent la [pseudo-classe `:where()`](https://developer.mozilla.org/fr/docs/Web/CSS/:where), dont la [spécificité](https://developer.mozilla.org/fr/docs/Web/CSS/CSS_cascade/Specificity) est de 0, ce qui signifie qu'il est facile de la remplacer par vos propres styles. Tout sélecteur CSS aura une spécificité plus élevée que `:where()`, vous pouvez donc facilement remplacer les styles en ajoutant vos propres styles pour cibler l'image.
-
-Vous pouvez remplacer les styles `object-fit` et `object-position` image par image en définissant les props `fit` et `position` sur le composant ` ` ou ` `.
-
-Vous pouvez désactiver entièrement les styles par défaut en définissant [`image.experimentalDefaultStyles`](/fr/reference/configuration-reference/#imageexperimentaldefaultstyles) sur `false` si vous préférez gérer vous-même le style des images adaptatives.
-
-#### Tailwind 4
-
-Tailwind 4 est un cas particulier, car il utilise [des couches en cascade](https://developer.mozilla.org/fr/docs/Web/CSS/@layer), ce qui signifie que les règles Tailwind sont toujours moins spécifiques que les règles qui n'utilisent pas de couches. Astro prend en charge les navigateurs qui ne prennent pas en charge les couches en cascade, il ne peut donc pas les utiliser pour les images. Cela signifie que [vous devez désactiver les styles par défaut](/fr/reference/configuration-reference/#imageexperimentaldefaultstyles) si vous avez besoin de les remplacer avec Tailwind 4.
-
-Pour une présentation complète et pour donner votre avis sur cette API expérimentale, consultez la [RFC Responsive Images](https://github.com/withastro/roadmap/blob/responsive-images/proposals/0053-responsive-images.md).
diff --git a/src/content/docs/ko/reference/experimental-flags/responsive-images.mdx b/src/content/docs/ko/reference/experimental-flags/responsive-images.mdx
deleted file mode 100644
index b66581f6488d0..0000000000000
--- a/src/content/docs/ko/reference/experimental-flags/responsive-images.mdx
+++ /dev/null
@@ -1,175 +0,0 @@
----
-title: 실험적 반응형 이미지
-sidebar:
- label: 반응형 이미지
-i18nReady: true
----
-
-import Since from '~/components/Since.astro'
-
-
-
-**타입:** `boolean`
-**기본값:** `false`
-
-
-
-프로젝트에서 자동 반응형 이미지 지원을 활성화합니다.
-
-[반응형 이미지](https://developer.mozilla.org/ko/docs/Web/HTML/Guides/Responsive_images)라는 용어는 다양한 기기에서 잘 작동하는 이미지를 의미합니다. 이는 특히 컨테이너에 맞춰 크기가 조절되는 이미지와 기기의 화면 크기 및 해상도에 따라 다른 크기로 제공될 수 있는 이미지에 적용됩니다.
-
-이미지가 표시되는 방식을 제어하기 위해 설정할 수 있는 여러 추가 속성이 있지만, 이러한 속성을 수동으로 직접 처리하는 것은 복잡할 수 있습니다. 이러한 속성을 잘못 처리하면 다운로드 속도가 느려지거나 이미지가 올바르게 표시되지 않을 수 있습니다. 이는 Core Web Vitals 및 Lighthouse 성능 점수가 낮게 측정되는 가장 흔한 원인 중 하나입니다.
-
-이 플래그가 활성화되면 Astro는 이미지에 필요한 `srcset` 및 `sizes` 값을 자동으로 생성하고, 올바르게 크기가 조정되도록 적절한 스타일을 적용할 수 있습니다. 이 동작은 전역적으로 또는 이미지별로 구성할 수 있습니다.
-
-해당 기능을 활성화하려면 먼저 `astro.config.mjs` 파일에 `responsiveImages` 플래그를 추가하세요.
-
-```js title="astro.config.mjs"
-{
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-기본적으로 이 플래그를 활성화해도 아무것도 변경되지 않지만, 전역적으로 또는 이미지별로 [이미지 레이아웃](#이미지-레이아웃)을 설정하여 반응형 이미지를 구성할 수 있습니다.
-
-이를 수행하기 위해 Astro에서 처리되고 최적화되는 모든 이미지의 기본 동작을 제어하는 추가적인 [`image` 구성 설정](#구성-설정)에 접근할 수 있습니다.
-
-- [Markdown의 `![]()` 구문](/ko/guides/images/#markdown-파일의-이미지)을 사용하는 로컬 및 원격 이미지
-- [` `](/ko/guides/images/#image--컴포넌트를-사용하여-최적화된-이미지-표시) 및 [` `](/ko/guides/images/#picture--컴포넌트를-사용해-반응형-이미지-만들기) 컴포넌트
-
-또한 Astro의 이미지 컴포넌트는 이미지별로 이러한 기본값을 재정의하기 위해 [반응형 이미지 props](#반응형-이미지-속성)를 받을 수 있습니다.
-
-`public/` 폴더의 이미지는 절대 최적화되지 않으며, 반응형 이미지는 지원되지 않습니다.
-
-:::note
-반응형 이미지를 활성화하면 영향을 받는 모든 이미지에 대해 추가 이미지 크기가 생성됩니다. 미리 렌더링된 페이지의 경우 빌드 중에 이 작업이 수행되므로 프로젝트 (특히, 이미지가 많은 프로젝트)의 빌드 시간이 늘어날 수 있습니다.
-
-요청 시 렌더링되는 페이지의 경우 이미지가 필요에 따라 생성되므로 빌드 시간에는 영향을 미치지 않지만 수행되는 변환 횟수가 증가할 수 있습니다. 이미지 서비스에 따라 추가 비용이 발생할 수 있습니다.
-:::
-
-## 이미지 레이아웃
-
-올바른 `srcset` 및 `sizes` 속성을 생성하기 위해 ` ` 및 ` ` 컴포넌트는 컨테이너 크기가 변경될 때 이미지의 크기가 어떻게 조정되어야 하는지 알아야 합니다. 이는 `layout` prop 또는 `image.experimentalLayout` 기본값을 설정하여 수행됩니다. 지원되는 값은 다음과 같습니다.
-
-- `constrained`: 이미지는 비율을 유지하면서 컨테이너에 맞게 축소되지만, 지정된 `width` 및 `height` 또는 이미지의 원래 크기 이상으로 확대되지는 않습니다. 가능한 경우 요청된 크기로 이미지를 표시하되, 작은 화면에 맞춰 축소하고 싶을 때 사용하세요. 이는 Tailwind를 사용할 때 이미지의 기본 동작과 일치합니다. 확실하지 않은 경우 이 레이아웃을 선택하는 것이 좋습니다.
-- `full-width`: 이미지는 비율을 유지하면서 컨테이너의 너비에 맞게 확대됩니다. 페이지의 전체 너비를 차지하는 히어로 이미지 또는 기타 이미지에 사용하세요.
-- `fixed`: 이미지는 요청된 크기를 유지하고 조정되지 않습니다. 고밀도 디스플레이를 지원하기 위한 `srcset`은 생성하지만, 다른 화면 크기에 대한 `srcset`은 생성하지 않습니다. 화면 너비보다 작은 아이콘이나 로고, 또는 고정 너비 컨테이너의 다른 이미지와 같이 이미지 크기가 조정되지 않을 경우에 사용하세요.
-- `none`: 이미지는 반응형으로 처리되지 않습니다. `srcset` 또는 `sizes`가 자동으로 생성되지 않으며, 스타일도 적용되지 않습니다. 기본 레이아웃을 활성화했지만 특정 이미지에 대해 비활성화하고 싶을 때 유용합니다.
-
-선택한 `layout`은 이미지에 대한 올바른 `srcset` 및 `sizes` 속성을 생성하는 데 사용되며, 해당 ` ` 태그에 적용되는 기본 스타일을 정의합니다.
-
-## 구성 설정
-
-프로젝트 전체에서 반응형 이미지를 활성화하려면 [`image.experimentalLayout`](/ko/reference/configuration-reference/#imageexperimentallayout)에 기본값을 설정하세요.
-
-이 값이 구성되지 않은 경우에도 ` ` 또는 ` ` 컴포넌트에 `layout` prop을 전달하여 반응형 이미지를 만들 수 있습니다. 그러나 Markdown 이미지는 반응형이 되지 않습니다.
-
-기본적으로 처리된 모든 이미지에 적용되는 [`image.experimentalObjectFit`](/ko/reference/configuration-reference/#imageexperimentalobjectfit) 및 [`image.experimentalObjectPosition`](/ko/reference/configuration-reference/#imageexperimentalobjectposition)을 선택적으로 구성할 수 있습니다.
-
-이러한 각 설정은 prop을 사용하여 개별 ` ` 또는 ` ` 컴포넌트에서 재정의할 수 있지만, Markdown 이미지는 항상 기본 설정을 사용합니다.
-
-```js title="astro.config.mjs"
-{
- image: {
- // 모든 Markdown 이미지에 사용되며, 이미지별로 구성할 수 없습니다.
- // prop으로 재정의되지 않는 한 모든 ` ` 및 ` ` 컴포넌트에 사용됩니다.
- experimentalLayout: 'constrained',
- },
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-## 반응형 이미지 속성
-
-반응형 이미지가 활성화되었을 때 ` ` 및 ` ` 컴포넌트에서 사용할 수 있는 추가 속성들입니다:
-
-- `layout`: 이미지의 [레이아웃 유형](#이미지-레이아웃)입니다. `constrained`, `fixed`, `full-width` 또는 `none`이 될 수 있습니다. `none`으로 설정하면 이 이미지에 대한 반응형 동작이 비활성화되고 다른 모든 옵션은 무시됩니다. 기본값은 `none`이거나, [`image.experimentalLayout`](/ko/reference/configuration-reference/#imageexperimentallayout)이 설정된 경우 해당 값입니다.
-- `fit`: 종횡비가 변경될 때 이미지를 어떻게 자를지 정의합니다. CSS `object-fit`의 값들과 일치합니다. 기본값은 `cover`이며, [`image.experimentalObjectFit`](/ko/reference/configuration-reference/#imageexperimentalobjectfit)이 설정된 경우 해당 값이 사용됩니다.
-- `position`: 종횡비가 변경될 때 이미지 자르기 위치를 정의합니다. CSS `object-position`의 값들과 일치합니다. 기본값은 `center`이며, [`image.experimentalObjectPosition`](/ko/reference/configuration-reference/#imageexperimentalobjectposition)이 설정된 경우 해당 값이 사용됩니다.
-- `priority`: 설정된 경우, 이미지를 즉시 로드합니다. 그렇지 않으면 이미지는 지연 로드됩니다. 첫 화면에서 가장 큰 이미지에 이 속성을 사용하세요. 기본값은 `false`입니다.
-
-`widths`와 `sizes` 속성은 이미지의 크기와 레이아웃 타입을 기반으로 자동 생성되며, 대부분의 경우 수동으로 설정할 필요가 없습니다. `constrained`와 `full-width` 이미지에 대해 생성된 `sizes` 속성은 뷰포트가 이미지 너비보다 작을 때 이미지가 화면 전체 너비에 가깝게 표시된다는 가정을 기반으로 합니다. 만약 이것이 상당히 다른 경우(예: 작은 화면에서 다중 열 레이아웃인 경우) 최상의 결과를 위해 `sizes` 속성을 수동으로 조정해야 할 수 있습니다.
-
-`densities` 속성은 반응형 이미지와 호환되지 않으며 설정하더라도 무시됩니다.
-
-예를 들어 `constrained`를 기본 레이아웃으로 설정한 경우, 개별 이미지의 `layout` 속성을 재정의할 수 있습니다.
-
-```astro
----
-import { Image } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-
-```
-
-## 반응형 이미지 HTML 생성 결과
-
-레이아웃이 기본적으로 또는 개별 컴포넌트에서 설정되면, 이미지는 크기와 레이아웃 유형에 따라 자동으로 생성된 `srcset` 및 `sizes` 속성을 갖게 됩니다. `constrained` 및 `full-width` 레이아웃을 가진 이미지는 컨테이너에 따라 크기가 조정되도록 스타일이 적용됩니다.
-
-```astro title=MyComponent.astro
----
-import { Image, Picture } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-```
-
-이 ` ` 컴포넌트는 다음과 같은 HTML 출력을 생성할 것입니다:
-
-```html
-
-```
-
-## 반응형 이미지의 기본 스타일
-
-반응형 이미지 컴포넌트는 크기를 올바르게 조정하기 위해 몇 가지 스타일을 적용합니다. 적용되는 스타일은 레이아웃 유형에 따라 다르며, 생성된 `srcset` 및 `sizes` 속성에 최적의 동작을 제공하도록 설계되었습니다.
-
-```css title="Responsive Image Styles"
-:where([data-astro-image]) {
- object-fit: var(--fit);
- object-position: var(--pos);
-}
-:where([data-astro-image='full-width']) {
- width: 100%;
-}
-:where([data-astro-image='constrained']) {
- max-width: 100%;
-}
-```
-
-### 기본 스타일 재정의
-
-해당 스타일은 [특이성](https://developer.mozilla.org/ko/docs/Web/CSS/CSS_cascade/Specificity)이 0인 [`:where()` 가상 클래스](https://developer.mozilla.org/en-US/docs/Web/CSS/:where)를 사용합니다. 이는 사용자 정의 스타일로 쉽게 재정의할 수 있음을 의미합니다. 모든 CSS 선택자는 `:where()`보다 높은 특이성을 가지므로, 이미지에 사용자 정의 스타일을 추가하여 스타일을 쉽게 재정의할 수 있습니다.
-
-` ` 또는 ` ` 컴포넌트에서 `fit` 및 `position` props를 설정하여 이미지별로 `object-fit` 및 `object-position` 스타일을 재정의할 수 있습니다.
-
-반응형 이미지를 직접 스타일링하고 싶다면, [`image.experimentalDefaultStyles`](/ko/reference/configuration-reference/#imageexperimentaldefaultstyles)를 `false`로 설정하여 기본 스타일을 완전히 비활성화할 수 있습니다.
-
-Tailwind 4는 [캐스케이드 레이어](https://developer.mozilla.org/ko/docs/Web/CSS/@layer)를 사용하기 때문에 특별한 경우입니다. 즉, 레이어를 사용하지 않는 규칙보다 Tailwind 규칙의 특이성이 항상 낮습니다. Astro는 캐스케이드 레이어를 지원하지 않는 브라우저를 지원하므로 이미지에 이를 사용할 수 없습니다. 즉, Tailwind 4를 사용하여 기본 스타일을 재정의하는 경우, [기본 스타일을 비활성화](/ko/reference/configuration-reference/#imageexperimentaldefaultstyles)해야 합니다.
-
-전체적인 개요를 확인하고 이 실험적인 API에 대한 피드백을 제공하려면 [반응형 이미지 RFC](https://github.com/withastro/roadmap/blob/responsive-images/proposals/0053-responsive-images.md)를 참조하세요.
diff --git a/src/content/docs/zh-cn/reference/experimental-flags/responsive-images.mdx b/src/content/docs/zh-cn/reference/experimental-flags/responsive-images.mdx
deleted file mode 100644
index b3e3804fa0d17..0000000000000
--- a/src/content/docs/zh-cn/reference/experimental-flags/responsive-images.mdx
+++ /dev/null
@@ -1,177 +0,0 @@
----
-title: 实验性响应式图像
-sidebar:
- label: 响应式图像
-i18nReady: true
----
-
-import Since from '~/components/Since.astro'
-
-
-
-**类型:** `boolean`
-**默认:** `false`
-
-
-
-启用以在你的项目中支持自动化响应式图像。
-
-[响应式图片](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Guides/Responsive_images),该术语是指在不同的设备上,都能得到良好展示效果的图片。响应式图片能够根据他们的容器来重新调整大小,并且能适配各个设备不同的屏幕尺寸与分辨率。
-
-尽管存在诸多额外属性可用于控制图像的显示方式,但手动处理这些属性可能较为复杂。若处理不当,可能会导致图片下载慢、展示效果异常。此类问题是 Core Web Vitals 和 Lighthouse 性能分数较低的最常见原因之一。
-
-当该标志启用时,Astro 将会自动生成图片所需的 `srcset` 和 `sizes` 值,并应用正确的方式以确保图片准确地调整尺寸。这些行为既可以全局配置,又可以在单个图像的基础上配置。
-
-要启用该功能,首先请在 `astro.config.mjs` 文件中,添加 `responsiveImages` 标志:
-
-```js title="astro.config.mjs"
-{
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-启用此标志后,不会对默认值进行更改,但是响应式图片接下来便可以通过 [图像布局](#图像布局) 进行全局、或是单个图像进行配置了。
-
-要进行配置,你需要访问另外的 [`image` 配置设置](#配置设置) 来控制 Astro 处理和优化所有图像的默认行为:
-
-- 使用 [Markdown `![]()` 语法](/zh-cn/guides/images/#markdown-文件中的图像)的本地和远程图像。
-- [` `](/zh-cn/guides/images/#使用-image--组件显示优化后的图像) 和 [` `](/zh-cn/guides/images/#使用-picture--组件创建响应式图像) 组件。
-
-此外,Astro 的图像组件可以接收 [响应式图像属性](#响应式图像属性) 以覆盖每个图像的默认值。
-
-你的 `public/` 文件夹中的图像永远不会被优化,且不支持响应式图像。
-
-:::note
-启用响应式图片将会为所有受影响的图片生成额外的图像尺寸。对于预渲染页面来说,这一步发生在构建阶段,因此可能会增加项目的构建时间,尤其是当图片数量较多时,这一点格外明显。
-
-对于按需渲染页面来说,图片也会按需生成,因此对构建时间没什么影响,但可能会增加图像处理的次数。根据你使用的图像服务,可能产生额外的开销。
-:::
-
-## 图像布局
-
-为了生成准确的 `srcset` 和 `size` 属性,` ` 与 ` ` 组件需要知道在容器尺寸发生更改时,图像应该如何变换。这个问题是由设置 `layout` 属性,或是 `image.experimentalLayout` 来默认处理。该属性支持的值有:
-
-- `constrained` - 图像按原始宽高比在容器内缩放,但不会超过指定的 `width` 和 `height` 以及图像的原始尺寸。此选项适用于需要适应较小屏幕尺寸的图像。该属性会在使用 Tailwind 时,为图像匹配默认的行为。如果你不确定你需要选哪种布局,那么此布局也许正是你应该选择的。
-- `full-width` - 图像宽度始终填满容器,并保持原始宽高比。此选项适用于主图,或是其他需要占据整个页面宽度的图片。
-- `fixed` - 图片保持指定的尺寸不变,不会随容器尺寸调整大小。生成 `srcset` 以支持高精度适配,但不会为不同屏幕生成其他比例的适配。此选项适用于固定比例图片,例如那些小于屏幕宽度的图标与 Logo,或是一些在固定容器尺寸中的图片。
-- `none` - 图像不会有响应式变化。不会自动生成 `srcset` 或 `sizes`,也不会应用不同的方式。此选项适用于在你启用了默认的布局,但是需要为特定的图片禁用响应式变化的情况。
-
-所选定的 `layout` 将会用于为图像生成准确的 `srcset` 和 `sizes` 属性,并为 ` ` 标签定义默认的应用样式。
-
-## 配置设置
-
-通过将 [`image.experimentalLayout`](/zh-cn/reference/configuration-reference/#imageexperimentallayout) 设置为默认值,以在整个项目中启用响应式图像。
-
-如果未配置此值,仍然可以为任何 ` ` 或 ` ` 组件传递 `layout` 属性以创建响应式图像。但是,Markdown 图像将不会是响应式的。
-
-此外,可以配置 [`image.experimentalObjectFit`](/zh-cn/reference/configuration-reference/#imageexperimentalobjectfit) 和 [`image.experimentalObjectPosition`](/zh-cn/reference/configuration-reference/#imageexperimentalobjectposition),这将默认应用于所有处理后的图像。
-
-每项设置都能通过属性在单个的 ` ` 或 ` ` 组件上被覆盖,但是 Markdown 图像将始终使用默认设置。
-
-```js title="astro.config.mjs"
-{
- image: {
- // 用于所有 Markdown 图像,不可按图像配置
- // 用于所有 ` ` 和 ` ` 组件,除非通过属性覆盖
- experimentalLayout: 'constrained',
- },
- experimental: {
- responsiveImages: true,
- },
-}
-```
-
-## 响应式图像属性
-
-当启用响应式图像时,有这些可用于 ` ` 和 ` ` 组件的附加属性:
-
-- `layout`:[图像布局] 的类型。可设置为 `constrained`、`fixed`、`full-width` 或 `none`。如果设置为 `none`,该图像的响应式行为将会被禁用,且所有其他选项都会被忽略。如果进行设置,其默认为 `none` 或 [`image.experimentalLayout`](/zh-cn/reference/configuration-reference/#imageexperimentallayout) 的值。
-- `fit`:定义在宽高比更改时应如何裁剪图像。该值与 CSS `object-fit` 的值匹配。默认为 `cover` 或 [`image.experimentalObjectFit`](/zh-cn/reference/configuration-reference/#imageexperimentalobjectfit) 的值(如果设置)。
-- `position`:定义宽高比更改时图像裁剪的位置。该值与 CSS `object-position` 的值匹配。默认为 `center` 或 [`image.experimentalObjectPosition`](/zh-cn/reference/configuration-reference/#imageexperimentalobjectposition)(如果设置)。
-- `priority`:如果设置该项,则立即加载图像。否则图像将被懒加载。可将其用于最大的首屏图像。默认为 `false`。
-
-`widths` 和 `sizes` 属性是基于图像的尺寸和布局类型自动生成的,大部分情况下不应手动设置。针对于 `constrained` 和 `full-width` 图像而生成的 `sizes` 属性是基于这样的假设:当视口小于图像的宽度时,图像以接近屏幕的全宽显示。如果明显不同时(例如,如果它在小屏幕上采用多列布局),你可能需要手动调整 `size` 属性以获得最佳结果。
-
-`densities` 属性无法与响应式图像兼容,如果设置则会被忽略。
-
-例如,将 `constrained` 设置为默认布局后,你可以覆盖任何单个图像的 `layout` 属性:
-
-```astro
----
-import { Image } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-
-```
-
-## 生成的响应式图像 HTML 输出
-
-设置布局(layout)后,图像会根据图像的尺寸和布局类型自动生成 `srcset` 和 `size` 属性。具有 `constrained` 和 `full-width` 布局属性的图像将应用样式,以确保它们根据容器来调整大小。
-
-```astro title=MyComponent.astro
----
-import { Image, Picture } from 'astro:assets';
-import myImage from '../assets/my_image.png';
----
-
-
-```
-
-这个 ` ` 组件将生成以下 HTML 输出:
-
-```html
-
-```
-
-## 响应式图像默认样式
-
-响应式图片组件会应用少量默认样式,以确保其在不同布局模式下正确调整尺寸。这些样式根据布局类型自动适配,旨在与生成的 `srcset` 和 `sizes` 属性协同工作,实现最佳显示效果:
-
-```css title="Responsive Image Styles"
-:where([data-astro-image]) {
- object-fit: var(--fit);
- object-position: var(--pos);
-}
-:where([data-astro-image='full-width']) {
- width: 100%;
-}
-:where([data-astro-image='constrained']) {
- max-width: 100%;
-}
-```
-
-### 覆盖默认样式
-
-使用 [`:where()` 伪类](https://developer.mozilla.org/zh-CN/docs/Web/CSS/:where) 的样式,它的 [优先级](https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_cascade/Specificity) 为 0,这意味着他可以轻松地被你个人的样式所覆盖。任何 CSS 选择器都具有比 `:where()` 更高的优先级,所以你可以轻松地针对图像添加类名或标签名,以实现新样式的覆盖。
-
-你可以在 ` ` 或 ` ` 组件中,通过设置 `fit` 和 `position` 属性来覆盖每个图像的 `object-fit` 和 `object-position` 样式。
-
-如果你需要自行处理响应式图像的样式,那么你可以通过将 [`image.experimentalDefaultStyles`](/zh-cn/reference/configuration-reference/#imageexperimentaldefaultstyles) 选项设置为 `false` 来完全禁用默认的样式。
-
-#### Tailwind 4
-
-Tailwind 4 是个特例,因为他使用了 [层叠层](https://developer.mozilla.org/zh-CN/docs/Web/CSS/@layer),这意味着 Tailwind 的 CSS 规则优先级始终低于未使用层叠层的规则。由于 Astro 需要兼容不支持层叠层的浏览器,因此其图片组件无法使用此特性。这导致:若需通过 Tailwind 4 覆盖 Astro 默认的图片样式,必须 [禁用默认样式](/zh-cn/reference/configuration-reference/#imageexperimentaldefaultstyles)。
-
-有关完整概述以及提供有关此实验性 API 的反馈,请参阅 [响应式图像 RFC](https://github.com/withastro/roadmap/blob/responsive-images/proposals/0053-responsive-images.md)。