Replies: 2 comments 6 replies
-
The way you would process those images would be to pass it to |
Beta Was this translation helpful? Give feedback.
-
Thanks Erika, I'm sure I can make
That way, you can define the image you want in your schema, rather than in the code where you're using it, which could be in multiple places (not DRY). I believe that this would result in cleaner code that is more intuitive, and easier to read and maintain. No? |
Beta Was this translation helpful? Give feedback.
-
Body
Summary
Optional parameters, like height, width and format, would allow a developer to specify what the generated image should look like as defined in their content collection schema.
Background & Motivation
Using this example:
we know that
blog.featuredImage
will give us an ImageMetadata object, that we can use, like<Image src={blog.featuredImage} height="768" with="1024" alt="Featured image"} />
and we get the image we want.However, suppose the developer wants to use
blog.ogImage
in a meta tag, like so:which will work, but the developer has no control over the size and format of the generated image. The result will always be the images native dimensions and webp, which is probably not optimal in most cases. For example, facebook accepts only certain MIME types: image/jpeg, image/gif or image/png for og:image.
Goals
Give developers control over images in content collection frontmatter:
Example
From the earlier example, we can add either params or an imageOptions param object:
Beta Was this translation helpful? Give feedback.
All reactions