Can anyone help me with making the right logic for this. I have found the string and I want the product to show the gallery, but when selecting a specific product variant (color and size) it should display the attached variant image.
When changing to ‘false’ it correct hides all the variant images, but do not show the attached variant picture unless you change variant again.
{%- for media in product.media -%}
{%- liquid
assign featured = false
if media == featured_media
assign featured = false
endif
I will try to explain in depth so I would like to have the attached variant image to display when variant is chosen and change whenever but I do not want all the other variant images to be available as product thumbnails.
SO an ideal product page would look like attached. I hope it makes sense.
Alright - thanks for your time. What is possible through .liquid.
I am not interested I paying an professional. I just want some simpel solution or a workaround. That sort of does the job.
The main issue right now, is when I remove the variant images from the product thumbnails with code the variant image do not appear until I change from default variant. Is it possible to just code it, so the product thumbnails only show like 4 images?
Maybe through CSS?
{%- for media in product.media -%}
{%- liquid
assign featured = false
if media == featured_media
assign featured = false
endif
When you use liquid, it will display the images in the default variant. So when you click change variant it won’t be able to load other images so you need more JS to be able to ajax load the image area again.
That’s why with liquid alone, this is not possible.
Or when you change variants, you need to reload the whole site, but it’s not really good, so adding JS to load ajax is the best solution.
Sure I understand. But is it possible just to let the variant images stay and code the slider to only show let’s say the first 4 images of the whole gallery. I’m the way I could exclude the variant images..???
You want to rearrange it, the 4 image gallery shows first and then the variant image list?
This is possible, you just need to change the code:
{%- for media in product.media -%}
{%- unless media.attached_to_variant? -%}
{%- endunless -%}
{%- endfor -%}
{%- for media in product.media -%}
{%- if media.attached_to_variant? -%}
{%- endif -%}
{%- endfor -%}
When you make these 2 loops it will give you a good display.