Shopify themes, liquid, logos, and UX
How can I display only certain variant images on my Shopify product page? I have multiple images for each product variant, but I want to only show a specific set of images for each selected variant. Any suggestions on how to achieve this?
Theme Broadcast v3.8.0
Store Password (1) : https://luxerefuge.myshopify.com
To display specific variant images on your product page, you can use the "data-variant-image" attribute in your code. Here's an example of what the code should look like:
{% if product.selected_or_first_available_variant.image.alt == "Variant Image 1" %}
<img src="{{ product.selected_or_first_available_variant.image.src | img_url }}" data-variant-image="1">
{% elseif product.selected_or_first_available_variant.image.alt == "Variant Image 2" %}
<img src="{{ product.selected_or_first_available_variant.image.src | img_url }}" data-variant-image="2">
{% endif %}
In the code above, replace "Variant Image 1" and "Variant Image 2" with the alt tags for the specific variant images that you want to display. You can also adjust the "data-variant-image" attribute to match the specific variant that the image is associated with.
Once you've added the code to your product page template, your customers will only see the specific variant images that you've designated for each selected variant.
If this fixed your issue, likes and accepting as a solution are highly appreciated.
Build an online presence with our custom built Shopify Theme EcomifyTheme
Hi,
Where can I find this code?
Thank you!
Hey @EcomGraduates,
I have updated the alt tags, but I'm not sure where to place the code. Could you please explain this a little?
Guys this video solved it. It is FREE without any App
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024