diff --git a/typo3/sysext/backend/Classes/Utility/BackendUtility.php b/typo3/sysext/backend/Classes/Utility/BackendUtility.php index 7efab50781d3fd535b3f2bcd2d81759879ae54d2..7de4240ff0ad2e01ababde38a188215ab836b36a 100644 --- a/typo3/sysext/backend/Classes/Utility/BackendUtility.php +++ b/typo3/sysext/backend/Classes/Utility/BackendUtility.php @@ -1051,7 +1051,7 @@ class BackendUtility * @param int|string $size Optional: $size is [w]x[h] of the thumbnail. 64 is default. * @param bool $linkInfoPopup Whether to wrap with a link opening the info popup * @return string Thumbnail image tag. - * @todo Unused in Core deprecate it! + * @deprecated Will be removed in TYPO3 v14 */ public static function thumbCode( $row, @@ -1065,6 +1065,7 @@ class BackendUtility $size = '', $linkInfoPopup = true ) { + trigger_error('BackendUtility::thumbCode() will be removed in TYPO3 v14.', E_USER_DEPRECATED); $size = (int)(trim((string)$size) ?: 64); $targetDimension = new ImageDimension($size, $size); $thumbData = ''; diff --git a/typo3/sysext/core/Documentation/Changelog/13.3/Deprecation-104662-BackendUtilityThumbCode.rst b/typo3/sysext/core/Documentation/Changelog/13.3/Deprecation-104662-BackendUtilityThumbCode.rst new file mode 100644 index 0000000000000000000000000000000000000000..38019f056ab4545a1b5689b79556d69f715ad3dc --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/13.3/Deprecation-104662-BackendUtilityThumbCode.rst @@ -0,0 +1,93 @@ +.. include:: /Includes.rst.txt + +.. _deprecation-104662-1724058079: + +=============================================== +Deprecation: #104662 - BackendUtility thumbCode +=============================================== + +See :issue:`104662` + +Description +=========== + +The method :php:`BackendUtility::thumbCode()` has been deprecated since the +method is no longer used in TYPO3 anymore. Additionally, due to multipe changes +to file processing over the years, e.g. introducing of FAL, the method's +signature changed a couple of times leading to a couple of method arguments +are being unused, which is quite a bad API. + +Impact +====== + +Calling the PHP method :php:`BackendUtility::thumbCode()` will +trigger a PHP deprecation warning. + +Affected installations +====================== + +TYPO3 installations with custom extensions using this method. The extension +scanner will report any usage as strong match. + + +Migration +========= + +Remove any usage of this method. In case you currently rely on the +functionality, you can copy it to your custom extension. However, you might +want to consider refactoring the correspoding code places. + +The method basically resolved given :php:`FileReference` objects. In case +a file could not be resolved, a special icon has been rendered. Otherwise, +the cropping configuration has been applied and the file's :php:`process()` +has been called to get the thumbnail, which has been wrapped in correspoding +thumbnail markup. This might has been extended to also open the information +modal on click. + +This means the relevant parts are: + +.. code-block:: php + + // Get file references + $fileReferences = BackendUtility:resolveFileReferences($table, $field, $row); + + // Check for existence of the file + $fileReference->getOriginalFile()->isMissing() + + // Render special icon if missing + $iconFactory + ->getIcon('mimetypes-other-other', IconSize::MEDIUM, 'overlay-missing') + ->setTitle(static::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:warning.file_missing') . ' ' . $fileObject->getName()) + ->render() + + // Process file with cropping configuration if not missing + $fileReference->getOriginalFile()->process( + ProcessedFile::CONTEXT_IMAGEPREVIEW,// ProcessedFile::CONTEXT_IMAGECROPSCALEMASK if cropArea is defiend + [ + 'width' => '...', + 'height' => '...', + 'crop' // If cropArea is defined + ] + ) + + // Use cropped file and create <img> tag + <img src="' . $fileReference->getOriginalFile()->process()->getPublicUrl() . '"/> + + // Wrap the info popup via <a> around the thumbnail + <a href="#" data-dispatch-action="TYPO3.InfoWindow.showItem" data-dispatch-args-list="_FILE,' . (int)$fileReference->getOriginalFile()->getUid() . '"> + + +Example of the HTML markup for a thumbnail: + +.. code-block:: html + + <div class="preview-thumbnails" style="--preview-thumbnails-size: 64px"> + <div class="preview-thumbnails-element"> + <div class="preview-thumbnails-element-image"> + <img src="' . $fileReference->getOriginalFile()->process()->getPublicUrl() . '" width="64px" height="64px" alt="' . $fileReference->getAlternative() ?: $fileReference->getName() . '" loading="lazy"/> + </div> + </div> + </div> + + +.. index:: PHP-API, FullyScanned, ext:backend diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 2acfa3ab5c209b82ce7bd81c5348816e42ddba06..232ba1a7cf6c97761a36d7d274ccf9f7a1950c24 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -1634,4 +1634,11 @@ return [ 'Deprecation-104607-BackendUserAuthenticationReturnWebmounts.rst', ], ], + 'TYPO3\CMS\Backend\Utility\BackendUtility::thumbCode' => [ + 'numberOfMandatoryArguments' => 3, + 'maximumNumberOfArguments' => 10, + 'restFiles' => [ + 'Deprecation-104662-BackendUtilityThumbCode.rst', + ], + ], ];