Změna logiky pro výběr obrázku receptu

This commit is contained in:
Emil Miler 2021-05-02 17:39:07 +02:00
parent 68aa36f416
commit 1f39452b3e

View File

@ -10,19 +10,15 @@
{% endif %}
>
<a href="{{ recipe.permalink }}">
{% set_global image_found = 0 %}
{% set_global image = "../static/temp.jpg" %}
{% for asset in recipe.assets %}
{% if asset is matching("[img.](jpg|png)$") %}
<img src="{{ resize_image(path=asset, width=300, height=300, op="fill") }}" alt="Náhled">
{% set_global image_found = 1 %}
{% set_global image = asset %}
{% break %}
{% endif %}
{% endfor %}
{% if image_found == 0 %}
<img src="/temp.jpg" alt="Náhradní obrázek">
{% endif %}
{% set_global image_found = 0 %}
{% if recipe.title %}<h3>{{ recipe.title }}</h3>{% endif %}
<img src="{{ resize_image(path=image, width=300, height=300, op="fill") }}" alt="{{ recipe.title }}">
<h3>{{ recipe.title }}</h3>
{% if recipe.date %}<span class="date">{{ recipe.date | date(format="%d.%m.%Y") }}</span>{% endif %}
</a>
</article>