Shopify themes, liquid, logos, and UX
Hi, I am trying to list file URLs of products in a collection
{% assign tracks = collections.frontpage.products | map: 'metafields.audiodemo.upload' %}
tracks = [
{% for track in tracks %}
"{{ track | file_url }}"{% unless forloop.last %},{% endunless %}
{% endfor %}
]
But this returns
trackNames = [ "//website.com/cdn/shop/files/?772", "//website.com/cdn/shop/files/?772", "//website.com/cdn/shop/files/?772" ]
However when I do
{% assign firstTrack = collections.frontpage.products.first.metafields.audiodemo.upload | file_url %}
{{ firstTrack }}
it returns the URL link for the first, so any reason why getting all the collection URLs are not working?
thanks
Solved! Go to the solution
This is an accepted solution.
Hi @ATVO5 ,
Try adding below code.
{% assign tracks = "" %}
{% for product in collections.frontpage.products %}
{% assign track = product.metafields.audiodemo.upload | file_url %}
{% capture tracks %}{{ tracks }}{{ track }}{% if forloop.last %}{% else %},{% endif %}{% endcapture %}
{% endfor %}
trackNames = [{{ tracks }}]
Thank you
This is an accepted solution.
Hi @ATVO5 ,
Try adding below code.
{% assign tracks = "" %}
{% for product in collections.frontpage.products %}
{% assign track = product.metafields.audiodemo.upload | file_url %}
{% capture tracks %}{{ tracks }}{{ track }}{% if forloop.last %}{% else %},{% endif %}{% endcapture %}
{% endfor %}
trackNames = [{{ tracks }}]
Thank you
Hello @ATVO5, Please try the below code.
{% assign tracks = collections.your_collection.products %}
tracks = [
{% for track in tracks %}
{% for image in track.images %}
"{{ image | json }}"{% unless forloop.last %},<br>{% endunless %}
{% endfor %}
{% endfor %}
]
See output below.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025