Load background image or thumbnail for each of the post in the list

This commit is contained in:
PCoder 2019-11-20 18:09:01 +05:30
commit c17057f7e8
2 changed files with 4 additions and 3 deletions

View file

@ -3,7 +3,8 @@
<div class="post-preview">
<div class="row">
<div class="col-md-4">
{% if from_index %}<h2><a href="{{ post|url }}"><img style="margin-top:11%" src="{{post.thumbnail}}"/></a></h2>{% else %}<h2><img style="margin-top:11%" src="{{post.thumbnail}}"/></h2>{% endif %}
{% set image = post.attachments.images.first() %}
{% if from_index %}<h2><a href="{{ post|url }}"><img src="{% if image %}{{ image.thumbnail(240)|url }}{% else %}/u/static/images/blog-post-placeholder.png{% endif %}" alt=""/></a></h2>{% else %}<h2><img src="{% if image %}{{ image.thumbnail(240)|url }}{% else %}/u/static/images/blog-post-placeholder.png{% endif %}" alt=""/></h2>{% endif %}
</div>
<div class="col-md-8">
{% if from_index %}<a href="{{ post|url }}"><h2 class="post-title">{{ post.title }}</h2></a>
@ -25,5 +26,4 @@
{% else %}
{{ post.body }}
{% endif %}
{% endmacro %}