sanity-io / sanity-plugin-media

Asset management plugin for Sanity
MIT License
160 stars 51 forks source link

Media Properties in preview object unknown #209

Open MokDevelopment opened 9 months ago

MokDevelopment commented 9 months ago

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 commented 9 months ago

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

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

closing the issue