Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Hero image, Antimatter

Started by Muut Archive 9 years ago · 3 replies · 785 views
9 years ago

Hey, dumb question but I'm just wondering if there's a simple way to set a hero/header image with the default Antimatter theme? I've looked into one of the skeleton themes and I'm wondering if just copying this section of the code would work? Or is there something else I would need to consider? Thanks all!

{% set blog_image = page.media.images %}
{% if blog_image %}
<div class="flush-top blog-header blog-header-image" style="background-image: url({{ blog_image.url }});">
{% else %}
<div class="blog-header">
{% endif %}
</div>

9 years ago

I've used something similar, and it works. I used page.media.images|first though, I'm not sure what .url does on a collection of images. There's no harm in trying!

9 years ago

Thanks a million! Kind of funny but just adding the |first fixed the whole problem.

9 years ago

Nice to hear! page.media.images returns an array with images from the folder of the page. It probably didn't work because you can't ask for the URL of a collection of images. You can however ask for the URL of the first image in the collection.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1338 9 years ago
Archive · by Muut Archive, 9 years ago
2 927 9 years ago
Archive · by Muut Archive, 9 years ago
2 4056 9 years ago
Archive · by Muut Archive, 9 years ago
1 2941 9 years ago
Archive · by Muut Archive, 9 years ago
3 1112 9 years ago