I want to show my featured image when its set, but when its not set I want to hide the featured image and show a placeholder that I have defined.
{% if featured-image != blank %}
<div><img src="{{ article | img_url: 'master' }}" loading="lazy" alt="{{ article.alt }}" class="featured_image"></div>
{% endif %}
{% if featured-image == blank %}
<div class="placeholder_image"></div>
{% endif %}
Currently its always showing the placeholder, even if the article has a featured image.
2
Answers
As mentioned earlier by @ComicsDansMS, this was the mistake. And also it should look like this:
{% if article.image != blank %}
One thing that jumps out at me is ‘featured-image’. Usually schema ID’s will use underscores, not hyphens. It might help to post that part of your schema code to see if there’s anything wrong there.
Checking the CLI for any errors might help as well (if you’re using the CLI).
Another thing you could do is use an
{% else %}
tag, instead of two IF tags, which will clean things up a bit.