Default Image

JoeLongstreet
New Member
2 0 0

How can I overwrite the default image for products. When an image doesn't exist, it looks like Shopify automatically outputs 

"<img src="https://cdn.shopify.com/s/images/admin/no-image-large.gif?da5ac9ca38617f8fcfb1ee46268f66d451ca66b4" alt="">"

from 

<img src="{{ product.featured_image | product_img_url: 'large' }}" alt="{{ product.featured_image.alt }}" />.

 

Is there somewhere in the admin I can upload a default image?

0 Likes
tetchi
Shopify Staff (Retired)
Shopify Staff (Retired)
489 0 43

You'll first have to upload an image to be your default image, then what you can do is check if a product has images using Liquid.

For example, let's say your new default image is called "default.png". On the collection/product template, you can do:

 

{% if product.images.size == 0 %} 
    {{ 'default.png' | asset_url | img_tag }}
{% else %}
   // show product image
{% endif %}

TLDR: You can use product.images.size and check if it's equal to zero; if it is, then show your new default image.

Hope that helps!

-tetchi 

 

www.tetchi.ca | www.twitter.com/t3tchi
JoeLongstreet
New Member
2 0 0

Perfect! Thanks.

0 Likes
terraslate
New Member
1 0 0

OK this is great.  How do I change the default image on an order confirmation email if it is a custom product - with no image other than the default?

0 Likes