Number of images for a variant

Venturesome
Tourist
13 0 1

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

Replies 4 (4)
drakedev
Shopify Partner
618 132 181

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.

If my answer was helpful click Like to say thanks
If the problem is solved remember to click Accept Solution
Shopify/Shopify Plus custom development: You can hire me for simple and/or complex tasks.
Venturesome
Tourist
13 0 1

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!!

drakedev
Shopify Partner
618 132 181

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

  1. Contact the app developers first, and ask if they can help you. Usually they are happy to help
  2. Hire a Shopify Partner/Dev/Expert that could help you to look into the details of the implementation
If my answer was helpful click Like to say thanks
If the problem is solved remember to click Accept Solution
Shopify/Shopify Plus custom development: You can hire me for simple and/or complex tasks.
made4Uo
Shopify Partner
1423 217 333

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.

Just be reminded that we are volunteering to help.
✿✿✿-

Likes  

and

 Accept as Solution

  will be much appreciated.✌-✿✿✿
For more Shopify Solutions and custom codes, just visit

 Made4Uo's website

.
Keep your stuffs private. Refrain from giving unnecessary access to your store.