I have an app that manages product images. My database already has image ids stored (“gid://shopify/ProductImage/xxx”) for when I need to replace them.
I see productImageUpdate is deprecated and I should use productUpdateMedia instead. However, productUpdateMedia requires the media image ID “gid://shopify/MediaImage/yyy”.
Is there a way I can map “gid://shopify/ProductImage/xxx” to its equivalent “gid://shopify/MediaImage/yyy”?
Hey @ko-lem - this is a great question! The easiest way to do this, I believe, would be to compare the URL values for the respective ProductImage GIDs and the MediaImage GIDs. Here’s an example GQL query you could use:
{
product(id: “gid://shopify/Product/7330367832086”) {
images (first:10) {
edges {
node {
id
url
}
}
}
media(first: 10) {
edges {
node {
id
… on MediaImage {
id
image {
id
url
}
mediaContentType
originalSource {
fileSize
}
}
}
}
}
}
}
The media image and product image objects should both have the same URLs (since they basically just represent the same image file in different contexts). Hope this helps - let me know if we can clarify anything on our end!
We appreciate your feedback! We’ll let the product team know it would valuable to have a connection or mapping between ProductImage and MediaImage objects.