From b0a29fa524a5265a4bf226ff2bb539a2133a5dd9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org>
Date: Tue, 6 Jun 2023 13:57:24 +0200
Subject: [PATCH] Display image in News Item on homepage

---
 .../news/templates/news/news_card_content.html           | 4 ++--
 .../scipost/templates/scipost/portal/_hx_home.html       | 9 ++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/scipost_django/news/templates/news/news_card_content.html b/scipost_django/news/templates/news/news_card_content.html
index 50b0cadfd..7835c8bf5 100644
--- a/scipost_django/news/templates/news/news_card_content.html
+++ b/scipost_django/news/templates/news/news_card_content.html
@@ -9,11 +9,11 @@
 	     src="{{ news.image.url }}" alt="image"/>
       </div>
       <div class="col-sm-9 col-lg-10">
-        <p class="mb-0">{{ news.blurb|safe }}</p>
+        <p class="mb-0">{{ news.blurb|safe|linebreaksbr }}</p>
       </div>
     </div>
   {% else %}
-    <p class="mb-0">{{ news.blurb|safe }}</p>
+    <p class="mb-0">{{ news.blurb|safe|linebreaksbr }}</p>
   {% endif %}
   {% if news.followup_link %}
     <a class="mt-3 d-inline-block" href="{{ news.followup_link }}">
diff --git a/scipost_django/scipost/templates/scipost/portal/_hx_home.html b/scipost_django/scipost/templates/scipost/portal/_hx_home.html
index fe8d020ae..70e7f3c3d 100644
--- a/scipost_django/scipost/templates/scipost/portal/_hx_home.html
+++ b/scipost_django/scipost/templates/scipost/portal/_hx_home.html
@@ -44,7 +44,14 @@
 	    <div class="date">{{ news.date|date:'d' }}<span class="month">{{ news.date|date:'M' }}</span></div>
 	    <div>
               <h3><a href="{% url 'news:news' %}#news_{{ news.id }}">{{ news.headline }}</a></h3>
-              <p>{{ news.blurb_short }}</p>
+	      {% if news.image %}
+		<div class="p-2">
+		  <img class="mb-3 mb-sm-0 {{ news.image.css_class }}"
+		       style="max-height: 80%; max-width: 80%;"
+		       src="{{ news.image.url }}" alt="image"/>
+		</div>
+	      {% endif %}
+              <p>{{ news.blurb_short|linebreaksbr }}</p>
 	    </div>
       	  </li>
       	{% endfor %}
-- 
GitLab