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

Retrieve metadata such as alt text #16

Closed
ericmasiello opened this issue May 8, 2020 · 2 comments
Closed

Retrieve metadata such as alt text #16

ericmasiello opened this issue May 8, 2020 · 2 comments

Comments

@ericmasiello
Copy link

Is it possible through the existing plugin to retrieve alt text specified in Cloudinary? Using GraphiQL, I did not see anything that resembled this data.

Thanks in advance!

@Chuloo
Copy link
Collaborator

Chuloo commented May 11, 2020

hi @ericmasiello you can do this by adding a context: true option in the gatsby-config options. Once this is done, any custom metadata or context data you add to the image on Cloudinary will be available in the context data field. Using the GraphiQL explorer, this is a sample query for all images:

query CloudinaryImage {
  allCloudinaryMedia {
    edges {
      node {
        context {
          custom {
            alt
          }
        }
        secure_url
        url
        public_id
      }
    }
  }
}

the node field with a context will return data like this, while other fields without context will return null for the context data:

{
          "node": {
            "context": {
              "custom": {
                "alt": "man-on-street"
              }
            },
            "secure_url": "https://res.cloudinary.com/chuloo/image/upload/q_auto,f_auto/v1580395766/gatsby-source-cloudinary/12.jpg",
            "url": "http://res.cloudinary.com/chuloo/image/upload/q_auto,f_auto/v1580395766/gatsby-source-cloudinary/12.jpg",
            "public_id": "gatsby-source-cloudinary/12"
          }
        }
@Chuloo Chuloo closed this as completed May 11, 2020
@ericmasiello
Copy link
Author

Thanks. I saw you updated the docs. 👍

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