astro:assets doesn't export ImageMetadata, making it hard to pass images as props.
hey anyone knows how to fix astro Image component type error
@astrojs/image overrides import type for images (including code in other frameworks like react)
astrojs - Import an image from an Astro.props variable - Stack Overflow
Videos
I've been building a blog/portfolio site using Astro with content collections and MDX. I'm trying to optimise images inside blog posts. Each post has multiple images, and I use a custom Astro component to display them with detailed captions in MDX files.
The issue is that Astro’s built-in Image component only works with statically imported images. That doesn’t play well with content collections and MDX, where importing each image manually isn’t practical, especially when posts have lots of images or grouped images with text blocks. Something would be limiting with just markdown syntax.
From what I’ve found, the dynamic import method using import.meta.glob() works, but it requires all images to live in a single folder. I’d prefer keeping assets organized inside each content folder (e.g., separate assets for blog/post vs. work), which that approach doesn’t really support.
The only other option seems to be putting everything in /public and using external tools for optimisation, but that feels like a workaround.
Has anyone faced this issue? How are you guys handling image optimisation in Astro with MDX and content collections?
» npm install @astrojs/image