commerce icon indicating copy to clipboard operation
commerce copied to clipboard

Link selected product image to the appropriate color variant

Open jazsouf opened this issue 4 months ago • 0 comments

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.

jazsouf avatar Oct 17 '24 09:10 jazsouf