Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
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.
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,
this is not working.. its not entering inside the for loop as there is no id..