From 17c977eeb921757f8a84e63362fe941326a1595c Mon Sep 17 00:00:00 2001 From: "pmoreno.rodriguez" <60596353+pmoreno-rodriguez@users.noreply.github.com> Date: Fri, 3 Feb 2023 23:19:04 +0100 Subject: [PATCH] Improved the definition of variables. Improved the definition of title, subtitle and image variables. --- templates/partials/miniposts.html.twig | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/templates/partials/miniposts.html.twig b/templates/partials/miniposts.html.twig index 9c104c5..6a18f91 100644 --- a/templates/partials/miniposts.html.twig +++ b/templates/partials/miniposts.html.twig @@ -1,5 +1,6 @@ {% set miniposts_category = theme_var('miniposts_category') %} {% set miniposts_number = config.theme.miniposts_number %} +{% set lang = grav.language.getActive ?: grav.config.site.default_lang %}
@@ -7,25 +8,29 @@
{% for p in page.evaluate({'@taxonomy.category':miniposts_category}).order('header.order', 'asc').slice(0,miniposts_number) %} + {% set image = p.media[p.header.primaryImage] ?: p.media.images|first %} + {% set title = p.title|raw %}

{{ p.title }}

{% if config.plugins["translate-date"].enabled %} - + + {% elseif config.plugins["twig-extensions"].enabled %} + {% else %} - + {% endif %} + {% if avatar %} + {% endif %}
+ {% if image %} - {% if p.header.primaryImage %} - {{ p.media[p.header.primaryImage].cropZoom(1038,437).loading('lazy').html('',p.title)|raw}} - {% else %} - {{p.media.images|first.cropZoom(1038,437).loading('lazy').html('',p.title)|raw}} - {% endif %} + {{ image.cropZoom(1038,437).loading('lazy').html(title,title)|raw}} + {% endif %}
{% endfor %}