Shopify themes, liquid, logos, and UX
Hi all,
I'm trying to print a list of files (images) through custom liquid code and for some reason, Shopify recognizes what I'm trying to do but only displays the placeholder "no image" instead of the images I added to the metaobject. As seen below:
The reason I'm doing it this way is because I want to be able to select a list of pictures I already uploaded for specific Influencers we partner with and doing it this way makes it easier for my co-workers to select pictures for each influencer, instead of having 9 different metafields inside the metaobject for each picture. I've shown my metaobject structure below:
I don't understand why it is not working as I can access the metaobject information fine (the following code prints the name fine:
{% assign influencers = shop.metaobjects.influencer.values %}
{% for influencer in influencers %}
<h2>{{ influencer.name }}</h2>
{% endfor %}
)
The code I'm using for the printing of the images is:
{% assign influencers = shop.metaobjects.influencer.values %}
{% for influencer in influencers %}
<h2>{{ influencer.name }}</h2>
{% assign gallery = influencer.gallery | split: ',' %}
{% for image in gallery %}
{% assign image_url = image | img_url: '500x' %}
<img src="{{ image_url }}" alt="{{ influencer.name }}">
{% endfor %}
{% endfor %}
If anyone has any idea what I'm doing wrong or how I can approach this differently, please help. I have been stuck on this for quite some while and feel like this should be doable. If not, also please tell me.
Thanks for ANY help in advance!
Solved! Go to the solution
This is an accepted solution.
{% assign influencers = shop.metaobjects.influencer.values %}
{% for influencer in influencers %}
<h2>{{ influencer.name }}</h2>
{% assign gallery = influencer.gallery.value %}
{% for image in gallery %}
{% assign image_url = image | img_url: '500x' %}
<img src="{{ image_url }}" alt="{{ influencer.name }}">
{% endfor %}
{% endfor %}
Why add this?
It is supposed to split the influencer.gallery values from a string to an array. If I remove that part, the code doesn't work anymore.
This is an accepted solution.
{% assign influencers = shop.metaobjects.influencer.values %}
{% for influencer in influencers %}
<h2>{{ influencer.name }}</h2>
{% assign gallery = influencer.gallery.value %}
{% for image in gallery %}
{% assign image_url = image | img_url: '500x' %}
<img src="{{ image_url }}" alt="{{ influencer.name }}">
{% endfor %}
{% endfor %}
Thanks! This seem to work! Can you explain to me what I did wrong?
Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025Shopify 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, 2025