ImageNotFound error in content collection item when using image().or(z.string())
#12673
Closed
1 task
Labels
- P3: minor bug
An edge case that only affects very specific usage (priority)
feat: content layer
Related to the Content Layer feature (scope)
Astro Info
If this issue only occurs in one browser, which browser is a problem?
Describe the Bug
When using
image().or(z.string())
in a content collection definition, Astro will always throw aImageNotFound
error, when a bare string is given instead of a local asset.We can define
and set
previewImage
to reference some asset in thepublic
directory to skip Astros image optimization.Now we'll always get
[ERROR] [ImageNotFound] Could not find requested image '/example.png'. Does it exist?
What's the expected result?
In Astro version
4.x.y
I could useimage().or(z.string())
to allow both referencing local assets, optimized by Astro and a bare string to give some public or external image url.In Astro version 5, it will always expect an existing image and throw error if a mere string is given.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-2q7gtw-wnxkkr?file=src%2Fcontent.config.ts
Participation
The text was updated successfully, but these errors were encountered: