Hi there i managed to change images (hide/show) on product variants when i click on another variant option (color), but when i enter on the product page, it show the first option checked by default, so how can i get only the image variants of checked option.
I'm using jquery, and this is my code by the moment;
filterMedia() {
$('[data-variant-color]').hide();
var selected_variant = this.currentVariant.featured_media.alt;
var selected_attribute = '[data-variant-color="' + selected_variant + '"]';
if (selected_variant == selected_variant) {
$(selected_attribute).show();
} }
Here is my preview url: https://se3yrx30jmzdugpl-64379486451.shopifypreview.com/products/basket-3-5
thanks in advance to anyone