Why is this not returning file URL?

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

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 %},
{% endunless %}
      {% endfor %} 
    {% endfor %}
]

See output below.