
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeLooking at your code, you're very close! The syntax for accessing array items in Sanity's preview select is to use dot notation with the index number, like 'vehicleContent.bilder.0' instead of 'vehicleContent.bilder[0]'.
Here's your corrected preview config:
preview: {
select: {
status: 'vehicleContent.synlighet.status',
modelName: 'vehicleContent.typeinfo.modellbetegnelse',
licensePlate: 'vehicleContent.identitet.licensePlate',
manufac: 'vehicleContent.typeinfo.manufacturer.label',
heroImage: 'vehicleContent.bilder.0', // Changed from [0] to .0
year: 'vehicleContent.datoer.FirstRegisterDate'
},
prepare({status, heroImage, modelName, year, licensePlate, manufac}) {
return {
media: heroImage, // Remove the template literal - just pass the value directly
title: `${licensePlate} - ${status.toUpperCase()}`,
subtitle: `${year ? year.split('-')[0] : ''} ${manufac ? manufac : ''} ${modelName ? modelName : ''}`
}
}
}Two key changes:
Array index syntax: Use 'vehicleContent.bilder.0' with dot notation rather than bracket notation [0]. This is the standard way to access array items in preview configuration.
Media value: Pass heroImage directly instead of wrapping it in a template literal (${heroImage}). The media property expects the actual image object, not a string representation of it.
If your image field is an image type with an asset reference, you might also want to be more specific and use 'vehicleContent.bilder.0.asset' to directly access the asset, though often just .0 works fine depending on your schema structure.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store