From 8a2f15653e755c59641a95a61cd32b6730c7e557 Mon Sep 17 00:00:00 2001
From: Willi Wehmeier <wwwehmeier@gmail.com>
Date: Tue, 5 Mar 2024 14:40:19 +0100
Subject: [PATCH] [TASK] Respect alt text in backend thumbnails
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The thumbCode method in the BackendUtility sets
the filename as the alt text for images. That's
why the backend representation of content elements
like textmedia doesn't respect any set alternative
text, whether it's set in the file_reference or
the sys_file record itself.

This change uses the alternative text and only
sets the filename as a fallback if there's no
alternative text provided for the file.

Resolves: #103285
Releases: main, 12.4
Change-Id: I3c11bb7a56f001e37eafdd1f0a998cb51fb2b460
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83213
Reviewed-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com>
Reviewed-by: Kevin Appelt <kevin.appelt@icloud.com>
Tested-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com>
Tested-by: Kevin Appelt <kevin.appelt@icloud.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
---
 typo3/sysext/backend/Classes/Utility/BackendUtility.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
index 5e1a124ec9a2..0e884307afc4 100644
--- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php
+++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php
@@ -1116,7 +1116,7 @@ class BackendUtility
                         'src' => $processedImage->getPublicUrl() ?? '',
                         'width' => $processedImage->getProperty('width'),
                         'height' => $processedImage->getProperty('height'),
-                        'alt' => $fileReferenceObject->getName(),
+                        'alt' => $fileReferenceObject->getAlternative() ?: $fileReferenceObject->getName(),
                         'loading' => 'lazy',
                     ];
                     $imgTag = '<img ' . GeneralUtility::implodeAttributes($attributes, true) . $tparams . '/>';
-- 
GitLab