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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Disable hero image for Quark item

Started by Robert 8 years ago · 4 replies · 1489 views
8 years ago

For some blog items, I would like to have images embedded in the post, bot NOT as a hero image. Unfortunately, if any image is with the item, a hero images is set.

Is there a way to disable this on a per-page base?

8 years ago

@metbril Do you mean the image displayed per item in the list of blog items? Or the image displayed at the top of a single blog item?

I presume the first...

In the template /templates/partials/blog-list-item.html.twig, there is the following code near the top:

TWIG
{% set image = page.media.images|first %}
{% if image %}
<div class="card-image">
    <a href="{{ page.url }}">{{ image.cropZoom(800,400).html }}</a>
</div>
{% endif %}

If any image is in the folder of the item, it will be displayed. To prevent this you could add an extra field in the blueprint item.yaml like 'no_header', or abuse the existing field 'header.header_image' and set it to 'disabled'. In the page's frontmatter it will show as:

TXT
header_image: '0'

If you change the code at the top of blog-list-item.html.twig as follows, the image will not be shown only if page.header.header_image is '0':

TWIG
{% set image = page.media.images|first %}
{% if image and page.header.header_image != '0' %}
<div class="card-image">
    <a href="{{ page.url }}">{{ image.cropZoom(800,400).html }}</a>
</div>
{% endif %}
👍 1
last edited 08/04/18 by pamtbaau
8 years ago

I had hoped the theme had a setting to disable this; a child theme will do as well, however.

8 years ago

Uhh yes, these changes should be done in a child theme...

Looking at the code, I cannot imaging there is a setting for this. And I don't understand why one would like to have a first image (alphabetically) to be shown at the top.... If I want one, let me pick one, just like the hero image...

8 years ago

Well, you can pick one (of you have more images in the folder), but if you don't, the theme will pick one for you. That is why I was asking...

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 57 15 hours ago
Support · by Anna, 3 days ago
2 65 18 hours ago
Support · by Justin Young, 19 hours ago
1 33 18 hours ago
Support · by Duc , 1 week ago
2 68 5 days ago
Support · by Colin Hume, 1 week ago
2 60 6 days ago