From 2a1cfdaaf4248a0eb11707f1a85c93ac68b40359 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Tue, 30 Mar 2021 12:52:58 +0200 Subject: [PATCH] [BUGFIX] Handle both t3:// and normal file names at once (#1716) Fixup for "[FEATURE] Handle t3://file?uid=23 URLs in view helper" The value of field gets different values in TYPO3 v9 and v10: - TYPO3 v9 stored the path to the filename, e.g. "fileadmin/user_upload/image.jpg" - TYPO3 v10 stores a t3:// URL, e.g. "t3://file?uid=2342" This patch automatically detects t3:// URLs in all image sources, regardless if $treatAsUid is given. That way the view helpers can load an image regardless if they have been stored in TYPO3 v9 or v10: --- .../Resource/AbstractResourceViewHelper.php | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Classes/ViewHelpers/Resource/AbstractResourceViewHelper.php b/Classes/ViewHelpers/Resource/AbstractResourceViewHelper.php index 8563013ac..a979ad9cd 100644 --- a/Classes/ViewHelpers/Resource/AbstractResourceViewHelper.php +++ b/Classes/ViewHelpers/Resource/AbstractResourceViewHelper.php @@ -90,19 +90,18 @@ public function getFiles($onlyProperties = false, $identifier = null, $categorie return null; } - if (true === $treatIdAsUid) { - foreach ($identifier as $key => $maybeUrl) { - if (substr($maybeUrl, 0, 5) !== 't3://') { - continue; - } - $parts = parse_url($maybeUrl); - if (false === isset($parts['host']) || $parts['host'] !== 'file' || false === isset($parts['query'])) { - continue; - } - parse_str($parts['query'], $queryParts); - if (true === isset($queryParts['uid'])) { - $identifier[$key] = $queryParts['uid']; - } + foreach ($identifier as $key => $maybeUrl) { + if (substr($maybeUrl, 0, 5) !== 't3://') { + continue; + } + $parts = parse_url($maybeUrl); + if (false === isset($parts['host']) || $parts['host'] !== 'file' || false === isset($parts['query'])) { + continue; + } + parse_str($parts['query'], $queryParts); + if (true === isset($queryParts['uid'])) { + $identifier[$key] = $queryParts['uid']; + $treatIdAsUid = true; } }