# Image - admin-graphql - OBJECT Version: 2025-01 ## Description Represents an image resource. ### Access Scopes ## Fields * [altText](/docs/api/admin-graphql/2025-01/scalars/String): String - A word or phrase to share the nature or contents of an image. * [height](/docs/api/admin-graphql/2025-01/scalars/Int): Int - The original height of the image in pixels. Returns `null` if the image isn't hosted by Shopify. * [id](/docs/api/admin-graphql/2025-01/scalars/ID): ID - A unique ID for the image. * [metafield](/docs/api/admin-graphql/2025-01/objects/Metafield): Metafield - A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * [originalSrc](/docs/api/admin-graphql/2025-01/scalars/URL): URL! - The location of the original image as a URL. If there are any existing transformations in the original source URL, they will remain and not be stripped. * [src](/docs/api/admin-graphql/2025-01/scalars/URL): URL! - The location of the image as a URL. * [transformedSrc](/docs/api/admin-graphql/2025-01/scalars/URL): URL! - The location of the transformed image as a URL. All transformation arguments are considered "best-effort". If they can be applied to an image, they will be. Otherwise any transformations which an image type doesn't support will be ignored. * [url](/docs/api/admin-graphql/2025-01/scalars/URL): URL! - The location of the image as a URL. If no transform options are specified, then the original image will be preserved including any pre-applied transforms. All transformation options are considered "best-effort". Any transformation that the original image type doesn't support will be ignored. If you need multiple variations of the same image, then you can use [GraphQL aliases](https://graphql.org/learn/queries/#aliases). * [width](/docs/api/admin-graphql/2025-01/scalars/Int): Int - The original width of the image in pixels. Returns `null` if the image isn't hosted by Shopify. ## Connections * [metafields](/docs/api/admin-graphql/2025-01/connections/MetafieldConnection): MetafieldConnection! ## Related queries ## Related mutations ## Related Unions ## Examples ### Get a metafield attached to an image Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ImageMetafield($variant: ID!, $namespace: String!, $key: String!) { productVariant(id: $variant) { image { attribution: metafield(namespace: $namespace, key: $key) { value } } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"attribution\",\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ImageMetafield($variant: ID!, $namespace: String!, $key: String!) {\n productVariant(id: $variant) {\n image {\n attribution: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"attribution\",\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query ImageMetafield($variant: ID!, $namespace: String!, $key: String!) {\n productVariant(id: $variant) {\n image {\n attribution: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"attribution\",\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query ImageMetafield($variant: ID!, $namespace: String!, $key: String!) {\n productVariant(id: $variant) {\n image {\n attribution: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"attribution\",\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ImageMetafield($variant: ID!, $namespace: String!, $key: String!) {\n productVariant(id: $variant) {\n image {\n attribution: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\n}" #### Graphql Input { "namespace": "my_fields", "key": "attribution", "variant": "gid://shopify/ProductVariant/43729076" } #### Graphql Response { "data": { "productVariant": { "image": { "attribution": { "value": "snowdevil street photography" } } } } } ### Get metafields attached to an image Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ImageMetafields($variant: ID!) { productVariant(id: $variant) { image { metafields(first: 3) { edges { node { namespace key value } } } } } }\",\n \"variables\": {\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ImageMetafields($variant: ID!) {\n productVariant(id: $variant) {\n image {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query ImageMetafields($variant: ID!) {\n productVariant(id: $variant) {\n image {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query ImageMetafields($variant: ID!) {\n productVariant(id: $variant) {\n image {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"variant\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ImageMetafields($variant: ID!) {\n productVariant(id: $variant) {\n image {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\n}" #### Graphql Input { "variant": "gid://shopify/ProductVariant/43729076" } #### Graphql Response { "data": { "productVariant": { "image": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "attribution", "value": "snowdevil street photography" } } ] } } } } }