Liquid, JavaScript, themes, sales channels
If anyone can help, that would be very appreciated.
I am building a store on the Spotlight theme and have the challenge that not all products having images.
So on collections, I want to make it so that if a product has no image there is a placeholder image that gets displayed instead.
In the product-card.liquid file the section that generates the product card, there's a check for the product's featured image
{%- if card_product.featured_media -%}
.... Display featured image....
{% endif %}
So I wedged a {% else %} in and copied all the code from the first if into the else statement.
under the else I used
{% assign placeholder = "product_placeholder.png" %}
and then replaced all the 'featured_image' references with {{ placeholder | asset_img_url: width: x }}
when inspecting, the image seems to pull through to the code correctly, but it still does not display?
Not sure how to check why the image is not showing, but would love some input that may help me resolve this
Hello @Nardu_M
Its Artzen Technologies! We will be happy to help you today.
PLease send me your store url, if applicable, the Password too.
Hi Artzen, here are the details for the store.
Store url: prestige-watch-wholesale.myshopify.com
password: rolexes
The file I've been editing is ../snippets/card_product.liquid
Generally there may be other logic that ends up controlling display in tandem with what you've edited.
Either externally or within the initial {% if %} condition.
Glancing over the url's code for /collections/all-products , NO media is loaded at all.
Double check the syntax of your image logic by validating it's parts in a custom-liquid block every step of the way, {{ placeholder}}etc etc.
If you need this debugged then contact me by mail for services, contact Info in signature.
Please always provide context, examples: store url, theme name, post url(s) , or any further detail.
Contact Info in signature.
Save time & money ,Ask Questions The Smart Way
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
Thank you Paul.
There was a conditional statement in one of the parent elements in the liquid code which prevented the images' display.
*The solution is not suitable to post on this forum
User | RANK |
---|---|
37 | |
29 | |
13 | |
12 | |
9 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023