images prop empty even though theyre added

Solved

images prop empty even though theyre added

ialusion
Tourist
5 0 1

I have been working my head around this;

It should be possible to access images via {{ images['somefilename'] | asset_image_url }} yet no matter what I attempt, it always returns a bad url. Even though the image files are clearly there.

I'm trying so that it'll decide which picture to use as the size chart depending on brand, gender etc.

It can determine properly which brand it is, it just does not find the correct foto file. (Which exists, case matching etc).

 

Hope anyone has a fix for this particular issue.

<h2 class="size-chart-title">{{section.settings.header}}</h2>

      {% if product.metafields.custom.brands == 'Adidas' %}
        {% assign chart = 'Adidas.png' %}
      {% elsif product.metafields.custom.brands == 'Gucci' %}
        {% assign chart = 'Gucci.png' %}
      {% endif %}

         
      <img src='{{ images[chart] | asset_img_url }}' alt="" style="width:20vw; height: 50vh">

      <script type='text/javascript'>
        console.log('{{ chart }}')
        console.log('{{ images[chart] | asset_img_url }}')
      </script>
Accepted Solution (1)
LitCommerce
Astronaut
2860 684 760

This is an accepted solution.

Hi @ialusion,

It is not static, it is changed according to the original condition you added. Refer:

Screenshot.png

Hope it helps!

 

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!

View solution in original post

Replies 6 (6)

StoreWatchers
Trailblazer
205 30 39

Hello @Ialusion

 
Greetings from the Store Watchers Support Team! Happy to help you today.
 
Please check the code below. 

 

 

<img src='{{ chart | asset_img_url }}' alt="" style="width:20vw; height: 50vh">

 

 
You can use the above code instead. Just remove the images[] from your code. I tested it on my end and works fine. Please check the below screenshot.
 
image.jpg

 
Let me know if need further assistance 
 

Regards,

Store Watchers Support Team

StoreWatchers - Automate testing for your Shopify store in seconds


If you find my reply helpful, please hit Like and Mark as Solution
Visit us: App Store | Website | FAQs
ialusion
Tourist
5 0 1

Hi there,

 

This is not what I mean. You're presetting a single image file. While I try to have one dynamic chart which changes on the same prop on various brands, etc.

 

This is why I need to do something like images[].

LitCommerce
Astronaut
2860 684 760

Hi @ialusion,

You can follow the instructions below:

- Step 1: Upload 2 images at Assets( Adidas.png and Gucci.png ).

- Step 2: Please change code:

<img src='{{ chart | asset_url }}' alt="" style="width:20vw; height: 50vh">

Hope it helps!

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
ialusion
Tourist
5 0 1

Same answer, just different way of telling it. Still what you are doing is one static image source. I need it to adapt based on conditions.

LitCommerce
Astronaut
2860 684 760

This is an accepted solution.

Hi @ialusion,

It is not static, it is changed according to the original condition you added. Refer:

Screenshot.png

Hope it helps!

 

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
ialusion
Tourist
5 0 1

Thank you, it did work. It was my fault for not trying it properly.