GraphQL API version: 2022-04
I’ve got the product images, they al have ids like “gid://shopify/ProductImage/32118981460142” but if i want to add this to a variant in need an id like this “gid://shopify/MediaImage/24456767406254”.
I use the productVariantAppendMedia mutation
But somehow there is no connection between then image in the product and the media file, but it is the same file?
The url is the same.
Is the only way, fetching both images and media and compare there url’s?
Hey @ErwinPlones - this is a great question. At the moment, the workaround you shared above is the easiest way to append an image quickly to a specific product variant, but you could also use a mutation like productVariantUpdate if you were looking for an easier way to just import non Shopify hosted URLs. For instance, you could set the product variant image based on the direct link to the image hosted on Shopify or on another file host. It might help cut down on how much you have to double check the URLs and just let you add any image file you’d like to the product variant.
In terms of the image and media files redirecting to the same image URL, this has to do with how the image itself is hosted on Shopify. A ProductImage and a MediaImage GID can redirect to the same hosted image. The different GIDs are used as a way to reference objects within the API and system itself rather than actually “being” the file, like an image in this case.
Let me know if we can clarify anything here - hope this helps with next steps. Cheers!
1 Like