Hide other variant images
Last updated
Last updated
By adding the alt
attribute to product images and grouping them by variant, you can achieve the effect of displaying only the image set for the currently selected variant. The specific steps are as follows:
alt
attribute to product images.In the product editing page, select the images you want to group and add an alt
attribute value, such as ###Purple
.
Images with the same alt
value (prefixed with ###
) will be grouped together.
The alt
attribute value must be prefixed with ###
to enable the grouping functionality.
In the variant settings, assign a main image to each variant. All images in the same group as the main image will be displayed when that variant is selected.
In the theme editor, go to the product settings and enable the "Hide Other Variant Images" option. Once enabled, only the current variant's image group will be displayed, while other images will be hidden.