Hello! I got a bit stuck on how to display multiple images metafield on my website. I want my client to be able to upload campaign pictures for each product:
The payload returned for this metafield type is an array of image objects. So you should process it accordingly. You may want to use code like this (with proper CSS rules applied, of course):
{% assign array_of_image_objects = product.metafields.custom.worn_images.value %}
{% if array_of_image_objects %}
{% for image_object in array_of_image_objects %}
{% endfor %}
{% endif %}
Thanks for the solution.
And is it possible to access/retrieve a specific file/image in a product metafield reference list, so it would show up on the website in the right place like it would be possible to do so with a metafield list single-line text, like the below code but instead for files/images?
First item in list: {{ product.metafields.custom.table.value[0] }}
ٍ
Second item in list: {{ product.metafields.custom.table.value[1] }}
Third item in list (seond): {{ product.metafields.custom.table.value[2] }}
Fourthitem in list: {{ product.metafields.custom.table.value.[3] }}
This is great, but what if my array could include images or videos? There must be a way to add an if, else if, else Logic to look at the file type and then display it in the correct way? Such as:
{% assign array_of_image_objects = product.metafields.custom.worn_images.value %}
{% if array_of_image_objects %}
{% for image_object in array_of_image_objects %}
{% if image_object.type=image %}
{% elseif image_object.type=video %}