commerce
commerce copied to clipboard
Link selected product image to the appropriate color variant
When selecting a product that has color variants like 'Acme T-Shirt', the gallery image relative to the selected color doesn't update.
Here is a little recording of the issue.
https://github.com/user-attachments/assets/16287f3c-7628-4a24-ae74-e6f0048dca23
Ideally, when a user selects the blue variant, the displayed image in the gallery should switch to the blue T-shirt image.
One way to do this, is filtering the gallery by reading and finding the correct image from the alt text. Something like gallery.find(image => image.alt.includes(searchParams.color)
.
I don't think Shopify allows to add metatags for media by variant. I could open a PR with the alt text solution but I wanted to check first if anyone can come up with a less hacky solution to this issue.