Variant metafield type List of files return string
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
If I used
{{ current_variant.metafields.custom.hero_images | json }}
result
{"error":"json not allowed for this object"}
If I used
{{ current_variant.metafields.custom.hero_images }}
result
["gid://shopify/MediaImage/31079273267451","gid://shopify/MediaImage/31079273300219"]
If I used
{%- assign hero_list = current_variant.metafields.custom.hero_images | split: ',' -%}
{{ hero_list[0] | json }}
result
"[\"gid:\/\/shopify\/MediaImage\/31079273267451\""
If I used
{{ current_variant.metafields.custom.hero_images.value | json }}
result
["\/\/cdn.shopify.com\/s\/files\/1\/0200\/6358\/4356\/files\/Black_-_Desktop.jpg?v=1666336384","\/\/cdn.shopify.com\/s\/files\/1\/0200\/6358\/4356\/files\/Black_-_Mobile.jpg?v=1666336384"]
But if I use
{{current_variant.metafields.custom.hero_images.value[0]}}
or
{% for value in current_variant.metafields.custom.hero_images.value }}
{{value}}
{%endfor%}
result -
null
How to transform this list that looks like an array to an object?
Or how I can get access for index in list files?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named. Start by reproducing the reported Liquid metafield snippets and inspect how list-of-files values are represented and accessed; completion would require a confirmed way to index or iterate the value, or a clearly documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100