Have your say in Community Polls: What was/is your greatest motivation to start your own business?

fetch collection files meta fields in shopify

fetch collection files meta fields in shopify

vikj
Not applicable
3 0 0

How do i fetch the collection.metafields.custom.collection_images data in the main-collection-product-grid.liquid.
I tried to fetch it but getting  
["gid://shopify/MediaImage/26512699457617","gid://shopify/MediaImage/26512699424849"] as output. I need to fetch the image url there.

 

Replies 2 (2)

willie087
Visitor
1 0 0

Hello!

Sure, here’s a shorter version:

{% for id in collection.metafields.custom.collection_images %}
{% assign image = shop.media_by_id[id | split: '//' | last | split: '/' | last] %}
<img src="{{ image | img_url: '300x300' }}" alt="">
{% endfor %}

This will loop through the IDs and output the image URLs.

 

 

Best Regards,

thedisneyhub

vikj
Not applicable
3 0 0

this is not working.. its not entering inside the for loop as there is no id..