From 793caf3ad7d1ebce6306e1711f466caeeb50ce0e Mon Sep 17 00:00:00 2001
From: ebremner <ebremner@uwaterloo.ca>
Date: Wed, 21 Mar 2018 10:58:25 -0400
Subject: [PATCH] ISTWCMS-2443: Updating preprocess for alt value and sending
 alt value in template

---
 .../paragraph--uw-para-marketing-block.html.twig           | 7 ++++++-
 uw_fdsu_theme_resp.theme                                   | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/templates/paragraphs/paragraph--uw-para-marketing-block.html.twig b/templates/paragraphs/paragraph--uw-para-marketing-block.html.twig
index 2952a542..73d76822 100644
--- a/templates/paragraphs/paragraph--uw-para-marketing-block.html.twig
+++ b/templates/paragraphs/paragraph--uw-para-marketing-block.html.twig
@@ -15,6 +15,10 @@
  *   or print a subset such as {{ content.field_example }}. Use
  *   {{ content|without('field_example') }} to temporarily suppress the printing
  *   of a given child element.
+ * - sources: The attributes of the <source> tags for this <picture> tag.
+ * - img_element: The controlling image, with the fallback image in srcset.
+ * - output_image_tag: Whether or not to output an <img> tag instead of a
+ *   <picture> tag.
  * - attributes: HTML attributes for the containing element.
  *   The attributes.class element may contain one or more of the following
  *   classes:
@@ -43,5 +47,6 @@
   "sources": sources,
   "marketing_text": content.field_uw_marketing_text|field_value.0['#text'],
   "output_image_tag": output_image_tag,
-  "img_element": img_element
+  "img_element": img_element['#uri'],
+  "alt": alt
 } %}
diff --git a/uw_fdsu_theme_resp.theme b/uw_fdsu_theme_resp.theme
index 62acde74..62b4c281 100644
--- a/uw_fdsu_theme_resp.theme
+++ b/uw_fdsu_theme_resp.theme
@@ -60,6 +60,9 @@ function _uw_fdsu_theme_resp_add_responsive_image_variables(&$variables, $field_
   // Get the field entity from the paragraph.
   $field = $variables['paragraph']->get($field_name)->first();
 
+  // Set the alt tag from the field entity.
+  $variables['alt'] = $field->get('alt')->getValue();
+
   // Set the file entity based on the field name.
   $file = $field->entity;
 
-- 
GitLab