Back to Withastro

Expected image options, not an ESM-imported image.

src/content/docs/en/reference/errors/expected-not-esmimage.mdx

latest647 B
Original Source

import DontEditWarning from '~/components/DontEditWarning.astro'

<DontEditWarning />

ExpectedNotESMImage: An ESM-imported image cannot be passed directly to getImage(). Instead, pass an object with the image in the src property.

What went wrong?

An ESM-imported image cannot be passed directly to getImage(). Instead, pass an object with the image in the src property.

diff
import { getImage } from "astro:assets";
import myImage from "../assets/my_image.png";
- const optimizedImage = await getImage( myImage );
+ const optimizedImage = await getImage({ src: myImage });

See Also: