0
votes

On a store im working on, when you follow a link to a specific variant (/products/the-product?variant=12345678901) the image on the product page is the featured image of the product. It needs to be the variant image of the selected variant.

How do I go about doing this? I've tried editing product.liquid to:

{% assign featured_image = product.selected_or_first_available_variant.featured_image %}

{% assign featured_image = variant.image %}

but neither work.

How should I do this?

1

1 Answers

1
votes

The proper way to target this is the following.

{% assign featured_image = product.selected_or_first_available_variant.image | img_url: 'master' %}

Refer to the Variant Object documentation: https://help.shopify.com/themes/liquid/objects/variant