sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
5.33k stars 430 forks source link

Unable to get Sanity image metadata informations #4297

Open sanjay-20896 opened 1 year ago

sanjay-20896 commented 1 year ago

We are not able to get sanity metadata information for a image field . We are using sanity studio version 2

 {
  name: 'imageDesktop',
  type: 'image',
  title: getTranslation("Image Desktop","en"),
  description: "Please add image of dimensions 1312 X 560",
  options: {
      metadata:['dimensions']
  }
},

Could you let us know what is wrong in this regard

rexxars commented 1 year ago

We're going to need some more information here. Where are you not getting the metadata you expect? The metadata is stored on the uploaded image asset document, while your image field holds a reference to that asset. More information here: https://www.sanity.io/docs/presenting-images#LAJMv3QY

This means that when querying for this information, you'll want to follow the asset field reference:

*[some groq filter here] {
  title,
  image {
    ..., // Include all the default image fields
    asset->, // Expand/follow the "asset" reference to include all metadata
  }
}
tirmey commented 7 months ago

There's a way to obtain custom image metadata, like image title, attributions, etc? I retrieved only camera settings from a jpg with a lot of useful infos registered in with the presented query.