sanity-plugin-media icon indicating copy to clipboard operation
sanity-plugin-media copied to clipboard

Media Properties in preview object unknown

Open MokDevelopment opened this issue 11 months ago • 1 comments

Hiya.

Thanks for the great plugin!

We are trying to setup a preview for the media references on media entity level within Sanity. We are somehow unable to wire the field id to the sanity preview selection. "title" for example is unknown.

"sanity": "^3.29.0", "sanity-plugin-media": "^2.2.5",

defineField({
	title: "Files",
	name: "files",
	type: "array",
	of: [
		{
			type: "file",
			preview: {
				//select: { title: "file.title" }, // unknown
				//select: { title: "media.title" }, // unknown
				select: { title: "title" }, // unknown
				prepare({ title }) {
					//console.log(selection)
					return {
						title: title,
					};
				},
			},
		},
	],

	options: {
		hotspot: true, // <-- Defaults to false
	},

	validation: (Rule) => Rule.required(),
}),

Is this a bug? Or is there a fancy property path we just dont know.

Thanks

MokDevelopment avatar Feb 27 '24 12:02 MokDevelopment

ok this here seems to be the correct way to bind the file properties.:

select: { title: "asset.title", asset: "asset" },

closing the issue

MokDevelopment avatar Feb 27 '24 16:02 MokDevelopment