Skip to main content

Querying for metadata and tags in GraphQL

Comments

5 comments

  • Mo Ip

    Hi Ted,

    You can use filter to retrieve "tags" and "context".  As an example:

    query {
    allCloudinaryMedia (
    filter: {
    tags: {
    eq: "mytag"
    }
    }
    ) {
    0
  • Ted Cook

    Hi Mo,

    From what I can tell there isn't a way to filter by tags. Was trying to in the explorer and that doesn't seem to be an option. From searching the forum further, I came across this issue that seems to suggest this is a feature in progress: https://support.cloudinary.com/hc/en-us/community/posts/360009584939-Product-gallery-and-image-alt-text

    When I mentioned description, I was referring to the "Description (alt)" field and title was in reference to "Title (caption)". Both are available for each photo uploaded in my Cloudinary image gallery and I was hoping to expose them along with my images on my personal site. Looks like I may have to wait on this feature or find another solution.

    0
  • Stephen Doyle

    Hi Ted,

    The feature request you linked is for our Product Gallery Widget which doesn't currently set caption or alt properties on the image tags it creates, but the mechanism by which that widget COULD add alt / caption properties automatically does exist, and could be used by you directly.

    The gallery widget uses a client-side resource list which is a JSON file containing a list of images matching a given tag. The response contains metadata about those images, including the context metadata like the Description and Title fields shown in Media Library: https://cloudinary.com/documentation/advanced_url_delivery_options#client_side_resources

    I'm not sure in your case what the data source is for your GraphQL queries (if you're using a third-party SDK or library to connect your code to our API, can you add a link please?) but if under the hood it's calling our Admin API's 'get resources' method or our Search API, there are parameters you can add to the calls so that the context metadata is included in our response.

    In the Search API you can add "with_field: context" ( https://cloudinary.com/documentation/search_api#parameters
    In the Admin API's 'get resources' method you can add "context: true" ( https://cloudinary.com/documentation/admin_api#get_resources

    May I ask you to take a look and let me know if that helps?

    Thanks,

    Stephen

    0
  • Ted Cook

    Hi Stephen,

    I'm not sure I'm following how to use GraphQL with those links. I'm trying to follow the Gatsby integration here: https://www.gatsbyjs.com/plugins/gatsby-source-cloudinary/

    In the example they give, they're returning images like this:

    but you can see there is no alt image being passed in in this case. Is this because it's potentially not available through their library? Thanks!

    0
  • Ted Cook

    Hi Stephen,

     

    Following up here... I seem to have solved my problem by doing some more digging. Looks like this was largely a case of me not having used GraphQL previously. I used this article here (https://www.freecodecamp.org/news/how-to-create-an-image-gallery-gatsby-and-cloudinary/) for guidance and changed my Graph query to this:

    I'm now getting the data I was looking for. Thanks for taking a look for me. I do appreciate your help!

    0

Post is closed for comments.