Correct way to query GraphQL for product image src

Quasar
Shopify Partner
2 0 3

Up until today I have been querying the Shopify GraphQL API with "originalSrc" in order to get product image sources. Now I see "originalSrc" is deprecated and that I should use "src" instead. My question is: how would this query with "src" look?

I have attempted to replace "originalSrc" with "src", which just returns a syntax error and I have not been able to find the solution anywhere online.

 

Here is my current (and deprecated) request

      {
            product(id: "gid://shopify/Product/6786957082804") {
                id
            images(first:10) {
            pageInfo {
                hasNextPage
                hasPreviousPage
                }
                edges {
                	cursor
                	node {
                		originalSrc
                		id
                    
                	}
                }
            }  
            }
        }

Thanks in advance!

Reply 1 (1)

Ole_
Shopify Partner
41 8 17

For future readers...

 

With the newest API updates, images is now deprecated. (Late 2023)

 

The new way to get image URLs is this:

{
  product(id: "gid://shopify/Product/6786957082804") {
    id
    media(first:10) {
      edges {
        node {
          ... on MediaImage {
            image {
              url
            }
          }
        }
      }  
    }
  }
}

This example will retrieve the URLs of all images, not including videos or other media types. 

If you find my suggestions helpful, kindly express your feedback by liking or marking them as a solution.

visionz.de