Skip to content

How to use Astro or NextJS <Image> with fields.document and fields.image #931

Answered by simonswiss
tordans asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!

I did some exploration on Astro Assets + Keystatic images (both fields.image and inside a component block) on a live stream yesterday.

The stream is very long and I get stuck on a lot of various (and unrelated) things — but essentially I got it working with a mix of:

  • defining the directory property of the fields.image to the assets folder, , and the publichPath to the relative path to the assets folder (../../assets/...).
  • defining the directory of component blocks to the assets folder as well, but the publicPath to /src/assets/... (because it needs to match Astro's dynamic imports with imports.meta.glob).

For component blocks I used the technique described here to import all images…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@JohannaPeanut
Comment options

@noahflk
Comment options

@jjaimealeman
Comment options

@simonswiss
Comment options

Answer selected by tordans
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants