Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions src/content/docs/en/guides/upgrade-to/v6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ import { ClientRouter } from 'astro:transitions';

<ReadMore>Read more about [view transitions and client-side routing in Astro](/en/guides/view-transitions/).</ReadMore>

### Removed: `emitESMImage()`

<SourcePR number="14426" title="feat!: remove emitESMImage()"/>

In Astro 5.6.2, the `emitESMImage()` function was deprecated in favor of `emitImageMetadata()`, which removes two deprecated arguments that were not meant to be exposed for public use: `_watchMode` and `experimentalSvgEnabled`.

Astro 6.0 removes `emitESMImage()` entirely. Update to `emitImageMetadata()` to keep your current behavior.

#### What should I do?

Replace all occurrences of the `emitESMImage()` with `emitImageMetadata()` and remove unused arguments:

```ts del={1,5} ins={2,6}
import { emitESMImage } from 'astro/assets/utils';
import { emitImageMetadata } from 'astro/assets/utils';

const imageId = '/images/photo.jpg';
const result = await emitESMImage(imageId, false, false);
const result = await emitImageMetadata(imageId);
```

<ReadMore>Read more about [`emitImageMetadata()`](/en/reference/image-service-reference/#emitimagemetadata).</ReadMore>

## Changed Defaults

Some default behavior has changed in Astro v5.0 and your project code may need updating to account for these changes.
Expand Down
42 changes: 0 additions & 42 deletions src/content/docs/en/reference/image-service-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -601,48 +601,6 @@ async function extractImageMetadata() {
await extractImageMetadata();
```

### `emitESMImage()`

:::caution[Deprecated]
Use the [`emitImageMetadata`](#emitimagemetadata) function instead.
:::

<p>
**Type:** `(id: string | undefined, _watchMode: boolean, experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter) => Promise<ImageMetadataWithContents | undefined>`<br />
<Since v="4.0.0" />
</p>


Processes an image file and emits its metadata and optionally its contents. In build mode, the function uses `fileEmitter` to generate an asset reference. In development mode, it resolves to a local file URL with query parameters for metadata.

```ts

import { emitESMImage } from 'astro/assets/utils';

const imageId = '/images/photo.jpg';
const unusedWatchMode = false; // Deprecated, unused
const unusedExperimentalSvgEnabled = false; // Set to `true` only if you are using SVG and want the file data to be embedded

try {
const result = await emitESMImage(imageId, unusedWatchMode, unusedExperimentalSvgEnabled);
if (result) {
console.log('Image metadata with contents:', result);
// Example output:
// {
// width: 800,
// height: 600,
// format: 'jpg',
// contents: Uint8Array([...])
// }
} else {
console.log('No metadata was emitted for this image.');
}
} catch (error) {
console.error('Failed to emit ESM image:', error);
}

```

### `emitImageMetadata()`

<p>
Expand Down