Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include metadata such as altText #67

Open
davidatthepark opened this issue Apr 17, 2024 · 2 comments
Open

Include metadata such as altText #67

davidatthepark opened this issue Apr 17, 2024 · 2 comments

Comments

@davidatthepark
Copy link

Is there a way to return metadata such as altText through this package? Or add this functionality?

My current situation:

  • Using sanity-plugin-media, I am able to add alt text to images in the media tab in studio.
  • I query an image reference to render on the frontend. for example -> urlFor(post.image).url()
  • I have to create a separate projection query for the metadata which includes alt text.
  image,
  imageMetadata {
     asset -> {_id, _type, url, altText}
 },

It would be nice if I didn't have to add the metadata in the query. Perhaps add a method like urlFor(post.image).metadata().altText(). Understandable if it's outside the scope of this library.

@LushawnDev
Copy link

Upvote for this, that'd be really useful!

@JamesSingleton
Copy link

Couldn't you do something like this?

"mainImage": {
    "caption": mainImage.caption,
    "attribution": mainImage.attribution,
    "crop": mainImage.crop,
    "hotspot": mainImage.hotspot,
    "asset": mainImage.asset->,
  },

This brings everything in for the asset including the altText

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants