You can access the image object from Astro by passing it as an argument to a function that returns your schema extension. This is demonstrated in the Astro documentation (https://starlight.astro.build/reference/frontmatter/#extend) where the image helper is used in a function that returns a Zod schema.
Here's an example of how you can do it:
import { defineCollection, z } from 'astro:content';
import { PostSchema } from './schema.ts';
export const collections = {
posts: defineCollection({
type: 'content',
schema: ({ image }) => PostSchema({ image }),
}),
};
And in your schema.ts file, you can define your PostSchema as a function that takes the image object as an argument:
import { z } from 'astro:content';
export const PostSchema = ({ image }) => z.object({
cover: image(),
});
This way, you can use the image helper from Astro in your separate schema file.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: