From 143bf7848abaa6ec22026bcd1b8c903f57484ca7 Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Mon, 27 Apr 2020 17:00:09 -0400
Subject: [PATCH] Improve record cover alt tags.

---
 themes/bootstrap3/templates/record/cover.phtml | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/themes/bootstrap3/templates/record/cover.phtml b/themes/bootstrap3/templates/record/cover.phtml
index 96666e065e3..7a0b37c5d56 100644
--- a/themes/bootstrap3/templates/record/cover.phtml
+++ b/themes/bootstrap3/templates/record/cover.phtml
@@ -1,8 +1,9 @@
 <?php /* Display thumbnail if appropriate: */ ?>
 <?php if ($cover): ?>
-  <?php if ($this->link): ?><a href="<?=$this->escapeHtmlAttr($this->link)?>" data-lightbox-image><?php endif; ?>
-  <img alt="<?=$this->transEsc('Cover Image')?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="recordcover" src="<?=$this->escapeHtmlAttr($cover); ?>"/>
-  <?php if ($this->link): ?></a><?php endif; ?>
+  <?php $alt = $this->link ? trim($this->driver->tryMethod('getTitle') ?? '') : ''; ?>
+  <?php if ($this->link && !empty($alt)): ?><a href="<?=$this->escapeHtmlAttr($this->link)?>"><?php endif; ?>
+  <img src="<?=$this->escapeHtmlAttr($cover); ?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="recordcover" alt="<?=$alt; ?>" />
+  <?php if ($this->link && !empty($alt)): ?></a><?php endif; ?>
 <?php else: ?>
-  <img src="<?=$this->url('cover-unavailable')?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="recordcover" alt="<?=$this->transEsc('No Cover Image')?>"/>
+  <img src="<?=$this->url('cover-unavailable')?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="recordcover" alt="" />
 <?php endif; ?>
-- 
GitLab