Open antitoxic opened 1 year ago
I have the same problem!
import {defineType, defineArrayMember} from 'sanity'
export default defineType({
name: 'gallery',
title: 'Gallery',
type: 'object',
fields: [
{
name: 'photos',
type: 'array',
options: {
layout: 'grid',
},
of: [
defineArrayMember({
type: 'photo',
}),
],
},
],
preview: {
select: {
photos: 'photos',
photo: 'photos.0',
},
prepare(selection) {
const {photos, photo} = selection
return {
title: 'Gallery',
subtitle: `${Object.keys(photos).length} photos`,
media: photo,
}
},
},
})
Console
If I prepend a new image, the previous image a index 0 (now at 1) shows up, but first entry is always undefined.
Same problem, did you find a solution?
Description & Reproduction
When you define schema like so, the preview image is not appearing even if there are images in
gallery
prop:Expected behavior
Show image as preview as per documentation. Same thing is working in V2.
Which versions of Sanity are you using?
What operating system are you using?
Which versions of Node.js / npm are you running?
Additional context When I try to select the entire collection
gallery
it seems that the first item is always empty:I tried: