mirror of
https://github.com/pmoreno-rodriguez/grav-theme-future2021.git
synced 2025-06-07 20:08:54 +00:00
New options for main image in miniposts
This commit is contained in:
parent
6f51b6d636
commit
6de9081d9f
1 changed files with 7 additions and 2 deletions
|
@ -19,6 +19,11 @@
|
|||
{% set title = p.title|raw %}
|
||||
{% set avatar = p.media[p.header.avatarImage].url|e %}
|
||||
{% set image = p.media[p.header.primaryImage] ?: p.media.all|filter((v, k) => k != p.header.avatarImage and (v.type == 'image' or v.type == 'vector'))|first %}
|
||||
|
||||
{# Define if the primary image and the attributes of width and height are shown #}
|
||||
{% set show_image = p.header.show_pageimage|defined(true) %}
|
||||
{% set img_width = p.header.image_width|default(1038) %}
|
||||
{% set img_height = p.header.image_height|default(437) %}
|
||||
|
||||
<article class="mini-post">
|
||||
<header>
|
||||
|
@ -36,9 +41,9 @@
|
|||
<a href="{{ p.url }}" class="author" title="{{ author }}"><img src="{{ avatar }}" alt="{{ author }}"/></a>
|
||||
{% endif %}
|
||||
</header>
|
||||
{% if image %}
|
||||
{% if show_image and image %}
|
||||
<a href="{{ p.url }}" class="image" title="{{ title|raw }}" rel="nofollow">
|
||||
{{ image.cropZoom(1038,437).loading('lazy').attribute('decoding','async').html(title,title)|raw}}
|
||||
{{ image.cropZoom(img_width,img_height).loading('lazy').attribute('decoding','async').html(title,title)|raw}}
|
||||
</a>
|
||||
{% endif %}
|
||||
</article>
|
||||
|
|
Loading…
Add table
Reference in a new issue