Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions src/content/docs/en/reference/modules/astro-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ import { Image } from 'astro:assets';

As of Astro 5.17.3, `inferSize` only fetches dimensions for [authorized remote image domains](/en/guides/images/#authorizing-remote-images). Remote images outside the allowlist are not fetched.

As of Astro 7.4.0, if fetching the remote image fails because of a transient network error (e.g. a connection reset, DNS lookup failure, or timeout), Astro will automatically retry the request up to two more times before failing.

#### `priority`

<p>
Expand Down Expand Up @@ -674,13 +676,15 @@ const optimizedBackground = await getImage({src: myBackground, format: 'avif'})
<Since v="4.12.0" />
</p>

A function to set the original `width` and `height` of a remote image automatically. This can be used as an alternative to passing the [`inferSize` ](#infersize) property.
A function to set the original `width` and `height` of a remote image automatically. This can be used as an alternative to passing the [`inferSize`](#infersize) property.

```ts
import { inferRemoteSize } from 'astro:assets';
const { width, height } = await inferRemoteSize("https://example.com/cat.png");
```

As of Astro 7.4.0, `inferRemoteSize()` automatically retries transient network errors in the same way as [`inferSize`](#infersize).

### `getConfiguredImageService()`

<p>
Expand Down Expand Up @@ -1259,20 +1263,7 @@ const origParams = getOrigQueryParams(url.searchParams);
<Since v="4.0.0" />
</p>

Infers the dimensions of a remote image by streaming its data and analyzing it progressively until sufficient metadata is available.

```ts
import { inferRemoteSize } from 'astro/assets/utils';

const remoteImageUrl = 'https://example.com/image.jpg';
const imageSize = await inferRemoteSize(remoteImageUrl);
// Example value:
// {
// width: 1920,
// height: 1080,
// format: 'jpg'
// }
```
See [`inferRemoteSize()` in `astro:assets`](#inferremotesize) for more details.

### `propsToFilename()`

Expand Down
Loading