-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
Description
It would be great if the media connection could be used for ProductVariant images, as you have done for Products.
At the moment, product.images
gives you an array of MediaImage
objects e.g.
[
[
"id" => "gid://shopify/MediaImage/1234567890"
"alt" => ""
"image" => array:4 [▶]
"createdAt" => "2021-08-09T16:28:29Z"
"updatedAt" => "2025-03-31T19:55:12Z"
"__parentId" => "gid://shopify/Product/1234567890"
"mediaContentType" => "IMAGE"
],
[
"id" => "gid://shopify/MediaImage/4567890123"
"alt" => ""
"image" => array:4 [▶]
"createdAt" => "2021-08-09T16:28:29Z"
"updatedAt" => "2025-03-31T19:55:12Z"
"__parentId" => "gid://shopify/Product/4567890123"
"mediaContentType" => "IMAGE"
],
]
However, variant.image
gives you a standard Image
object e.g.
"id" => "gid://shopify/ProductImage/1234567890"
"src" => "https://cdn.shopify.com/s/files/1234567890"
"url" => "https://cdn.shopify.com/s/files/1234567890"
"width" => 1000
"height" => 768
"altText" => null
Previously, I was able to find a variant's image in the parent product's image array by id. This was useful when switching to a different variant on a product page and updating the main product image respectively. However now I don't see a way to match them given the different URIs.
It's interesting that the Images connection on Product has been deprecated, yet Image on ProductVariant continues to live alongside the newer Media connection.