From 504abbed3069e4236cb11c305881c87881cbcc4c Mon Sep 17 00:00:00 2001 From: Nikita Hovratov <nikita.h@live.de> Date: Fri, 23 Dec 2022 14:56:08 +0100 Subject: [PATCH] [BUGFIX] Handle absolute web paths in FormEngineUtility::getIconHtml Since the introduction of always absolute (web) paths inside the TYPO3 backend, the TCA ctrl option `selicon_field` didn't work anymore since relative web paths like `fileadmin/file.png` changed to `/fileadmin/file.png`, which were not handled and resulted in a missing icon. This patch extends the condition for checking for absolute paths and prevents the GU:getFileAbsFileName method from turning web paths into empty strings. Resolves: #95572 Resolves: #97442 Related: #95027 Releases: main, 11.5 Change-Id: I1b82f71fe4f0636bd786d102f361ca60c1294af9 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77431 Tested-by: core-ci <typo3@b13.com> Reviewed-by: Nikita Hovratov <nikita.h@live.de> Tested-by: Nikita Hovratov <nikita.h@live.de> --- .../backend/Classes/Form/Utility/FormEngineUtility.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php b/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php index 535daa845f45..8e666fe70444 100644 --- a/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php +++ b/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Form\Utility; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Utility\ArrayUtility; @@ -122,8 +123,12 @@ class FormEngineUtility public static function getIconHtml($icon, $alt = '', $title = '') { $icon = (string)$icon; - $absoluteFilePath = GeneralUtility::getFileAbsFileName($icon); - if (!empty($absoluteFilePath) && is_file($absoluteFilePath)) { + if (PathUtility::isAbsolutePath($icon)) { + $absoluteFilePath = $icon; + } else { + $absoluteFilePath = GeneralUtility::getFileAbsFileName($icon); + } + if (!empty($absoluteFilePath) && (is_file($absoluteFilePath)) || is_file(Environment::getPublicPath() . $absoluteFilePath)) { return '<img' . ' loading="lazy" ' . ' src="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($absoluteFilePath)) . '"' -- GitLab