Liquid, JavaScript, themes, sales channels
Hello
i would like to know if there is an object that returns how many images a variant has. Something like {{product.images.size}} but only for a variant (e.g i have a shirt with 3 colors red,blue and yellow and i would like to know how many images the yellow variant has )
thanks in advance
Hi @Venturesome welcome to Shopify Community.
By default Shopify allow to associate only 1 image to 1 variant. That image can be retrieved by using the variant object.
{{ variant.image.src }}
If you want to associate more images to a single variant you need to implement some custom code and store the additional variant object in Shopify custom metafields (for example).
Or there are specific apps that allow to solve this problem, like Variant Image Automator and various others.
hi drakedev thanks for the response
The thing is i already have an app that sorts the images of variant and it works perfectly well in most cases .The problem arises when i want for product to have different number of images for each variant.
For example the t-shirt i mentioned may have 1 image for the red variant 2 for blue variant 3 for yellow .When that happens they appear correctly with the app 1 for red 2 for blue 3 for yellow but the aspect ratio is not what i want . I want to insert a liquid condition in order to when for example its 1 image have full width when its 2 to have 50% etc .thanks for the response tho i ll look into it!!
Oh I see, in this case is not easy to help you for me.
Maybe you can mention here the name of the app you are using and show what happen by linking an URL and you can maybe found someone that knows that app and can give you a hint.
Otherwise your best shots are
Hi,
There is no variant images JSON. You can create one for your self though. If you are looking on associating images with variants, check the video below.
If you have Dawn theme or Any Shopify 2.0 FREE themes, this should work. No APPs or EXTERNAL library needed. The code is made to call all the variant options related images. You can have multiple variants options. Works with the Dawn product settings too, that includes thumbnail carousel and even the media size settings.
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024