can't display products images using liquid

Solved

can't display products images using liquid

Bontalexel31
Shopify Partner
28 2 4

Hey guys,

I can't display my product images using this liquid snippet from the shopify liquid cheatsheet.

 

 

{% for image in product.images %}
  <img src="{{ image.src | product_img_url: 'medium' }}">
{% endfor %}

 

 


Is there any other way I could display all images of a product on demand with another liquid snippet?

Show Variant Options as Text or Colored Swatches with Add to cart Button on Home and Collection Page
Install it now for free!
Swatch Display: https://apps.shopify.com/swatch-display
Accepted Solution (1)
Bontalexel31
Shopify Partner
28 2 4

This is an accepted solution.

I found this one to work best for me.

{% for image in product.images %}
                {{ image | image_url: width: 30, height:30 | image_tag}}
            {% endfor %}

 What do you guys think about it?

Show Variant Options as Text or Colored Swatches with Add to cart Button on Home and Collection Page
Install it now for free!
Swatch Display: https://apps.shopify.com/swatch-display

View solution in original post

Replies 4 (4)

Dan-From-Ryviu
Shopify Partner
11376 2231 2404

Hi @Bontalexel31 

You can try to use this code instead.

 {%- for media in product.media -%}     
 {{
        media.preview_image
        | image_url: width: 1946
        | image_tag:
          loading: lazy,
          sizes: 500,
          widths: '246, 493, 600, 713, 823, 990, 1100, 1206, 1346, 1426, 1646, 1946'
  }}
{%- endfor -%}

- Found this helpful? Hit "Like" and "Accept as Solution"! Support me: Donate!
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
Built for Shopify

Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...
Sign up now.

tim
Shopify Partner
4006 420 1477

Instead of 

 <img src="{{ image.src | product_img_url: 'medium' }}">

You should do

 <img src="{{ image | product_img_url: 'medium' }}">

 image.src is a string, but product_img_url expects image object as input.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
Bontalexel31
Shopify Partner
28 2 4

This is an accepted solution.

I found this one to work best for me.

{% for image in product.images %}
                {{ image | image_url: width: 30, height:30 | image_tag}}
            {% endfor %}

 What do you guys think about it?

Show Variant Options as Text or Colored Swatches with Add to cart Button on Home and Collection Page
Install it now for free!
Swatch Display: https://apps.shopify.com/swatch-display
tim
Shopify Partner
4006 420 1477

It's fine both ways.

product_img_url is and old way of creating image URLs, image_url is a newer one. 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com