To get a product's slideshow gallery to automatically switch to the correct variant image, you'll need to add/select an image for each variant within the Shopify admin. Here's how to do that:
- In the Shopify admin, navigate to the product you want to edit.
- Scroll down to the list of variants.
- Click the small image thumbnail to the left of the variant title.
- This will open a box to select from the available images that are associated with the product (i.e. any image that you've uploaded to the product's "main" media).
- Select the image for that variant (or upload a new one). (Note that you can use the same image for multiple variants! i.e. If you have a t-shirt product with red, blue, and black variants, which are also available in small, medium, and large — you would add the red t-shirt image to all red variants (i.e. the red/small variant, the red/medium variant, and the red/large variant... Unless you actually have different images for these!)
- Save your work.
Here's a quick screencapture of the process: