Printing Images from metaobject list

Printing Images from metaobject list

Rueben
Shopify Partner
4 0 0

Hi Everyone,

 

I have a shop where we collaborate with influencers and now I want to highlight these influencers even more. To do that I have created a metaobject called influencer with the fields: .name, .picture, .instagram and .gallery. I think every field speaks for itself, except gallery. In the gallery field I have enabled "lists of files" because I want to create a page for the influencer metaobject where I can print each image/file inside this .gallery. I have gotten as far as to creating the following code:

{% 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 %}
It seems like this works, but instead of printing the images it prints "No image" as seen below.

Rueben_0-1718971155406.gif

Does anyone know why this is happening or what I'm doing wrong? Any help is greatly appreciated. I have been stuck on this for a week...

Reply 1 (1)

NeilMaggy
Shopify Partner
30 2 3

Not directly related,

But if you want to maintain influencers details for this shop for new ones, you should use https://apps.shopify.com/creator-gift-link to send them gifts. That way you can collect their IG/TikTok when sending them products and not have to keep a separate list of all the influencers the shop works with.