From 19714f20fa7c835b9b815db38fd27e1475361baf Mon Sep 17 00:00:00 2001
From: Michael Lee <lee.5151@osu.edu>
Date: Wed, 7 Aug 2024 13:30:31 -0400
Subject: [PATCH] Add hook to add a11y text to file media

---
 .../asc_bootstrap_bux/asc_bootstrap_bux.theme      | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme b/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme
index 5c1524493c..efff413f99 100755
--- a/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme
+++ b/web/themes/asc_bootstrap_bux/asc_bootstrap_bux.theme
@@ -1141,3 +1141,17 @@ function asc_bootstrap_bux_preprocess_views_exposed_form(&$variables)
     }
   }
 }
+
+/**
+ * Appends accessible text to File media when it opens in a new tab.
+ */
+function asc_bootstrap_bux_preprocess_file_link(array &$variables)
+{
+  $link = $variables['link'];
+  $attributes = $link->getUrl()->getOption('attributes');
+  if (isset($attributes['target']) && $attributes['target'] === '_blank') {
+    $string = $link->getText();
+    $string .= " (opens in a new window)";
+    $link->setText($string);
+  }
+}
-- 
GitLab