From e63c3809eb6b3a2fc3b7a79de34daa086c8c9a35 Mon Sep 17 00:00:00 2001
From: ebremner <ebremner@uwaterloo.ca>
Date: Thu, 17 Jun 2021 01:21:58 -0400
Subject: [PATCH] ISTWCMS-4704: adding logic for featured image

---
 .../04-components/card/card--node/card--node.twig         | 1 +
 source/_patterns/04-components/card/card.twig             | 8 +++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/source/_patterns/04-components/card/card--node/card--node.twig b/source/_patterns/04-components/card/card--node/card--node.twig
index 361e2c04..384e351a 100644
--- a/source/_patterns/04-components/card/card--node/card--node.twig
+++ b/source/_patterns/04-components/card/card--node/card--node.twig
@@ -21,4 +21,5 @@
   'additional_info': node.additional_info,
   'contact_for': node.contact_for,
   'groups': node.groups,
+  'featured_image': 'yes',
 } %}
diff --git a/source/_patterns/04-components/card/card.twig b/source/_patterns/04-components/card/card.twig
index 08472783..beb96061 100644
--- a/source/_patterns/04-components/card/card.twig
+++ b/source/_patterns/04-components/card/card.twig
@@ -1,6 +1,12 @@
 {% import '@base/macros/uw.macro.twig' as macros %}
 
 <article class="card {{ modifier_classes }} {% if show_hover %} card--show-hover {% endif %} {{ type }}" >
+
+  {% if featured_image and img_element %}
+    <div class="card__featured-image" style="background-image: url({{ img_element }});" role="img" aria-label="{{ alt }}">
+    </div>
+  {%  endif %}
+
   <div class="card__body">
     {% if title or author or date or sub_title %}
       <div class="card__header">
@@ -41,7 +47,7 @@
         {% endif %}
       </div>
     {% endif %}
-    {% if sources or img_element %}
+    {% if not featured_image and (sources or img_element) %}
       <div class="card__media">
         {% if url %}
           <a href="{{ url }}">
-- 
GitLab