Default Header Image in posts

How would I set up header image for every blog post on Casper2 as default one?

So - basically I want default image to show up for every post on which I didn’t set up any other image,
so that posts aren’t without image, but would have default one.

1 Like


{{#unless feature_image}}
    <img src="path/to/img.jpg" alt="My default image" />

This doesn’t work for me. :fearful:

I get "> displayed instead of image.

Sounds like you might’ve typo’d/missed a quote mark


Thank You very much, it works now. :slight_smile:

1 Like

just a little update on this one, in case it might come in handy to anyone in the future.

above code is great as starting point, but since featured image is in a div, this one must be as well,
otherwise it’s height is bigger, which disrupts nice look of blog cards.

    {{#unless feature_image}}
<div class="post-card-image" style="background-image: url(" alt="cover"></div>

this is all in file called : post-cards.hbs

This could be also a nice official addition to Casper theme, now when I think about it.
But I’m not sure how would setting of background image by user be made possible.
Probably via Ghost’s admin panel.

{{#if feature_image}}
<img src = "{{img_url feature_image}}" alt = "{{title}}"/>
<img src = "{{asset "path/to/default/img.jpg"}}" alt = "{{title}}"/>

Hope this helps! :slight_smile: