This is what I'm using, and I am able to edit my images:
interface Fields {
data: {
item: {
pageTitle: {
jsonValue: string
},
Text: {
jsonValue: string
},
children: {
results: RecentNewsResults[]
}
}
}
}
interface RecentNewsResults {
pageTitle: {
jsonValue: string
},
Intro: {
jsonValue: string
},
Date: {
jsonValue: string
}
Image: {
jsonValue: ImageField
},
url: {
path: string
}
}
export type RecentNewsProps = {
params: { [key: string]: string };
fields: Fields;
};
export const Default = (props: RecentNewsProps): JSX.Element => {
...
{props.fields.data.item.children.results.map((child, index) => (
<Image field={child.Image.jsonValue} />
))}
...
};
The above does not use GraphQL
but that should work exactly the same in terms of rendering it out - just grab the jsonValue
and use that in your Image
field.
edit
Just as the NextImage
component mentioned in Mahendra's answer, the Image
component does also have properties to be able to resize, make editable true/false etc.