[BUGFIX] Resolve t3: URI to FAL objects for src attributes 28/53428/2
authorJigal van Hemert <jigal.van.hemert@typo3.org>
Fri, 7 Jul 2017 11:58:32 +0000 (13:58 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Mon, 10 Jul 2017 17:25:25 +0000 (19:25 +0200)
Files in FAL can be linked with a t3://file link. Those URIs can
now be used in e.g. src attributes of the image viewhelper.
In v7 links to files had the format "file:<uid>" and those are supported
in such cases.

Resolves: #81820
Releases: master, 8.7
Change-Id: I6dbda26df0dfc4f4272425b9f2c0099e2d710015
Reviewed-on: https://review.typo3.org/53428
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/extbase/Classes/Service/ImageService.php

index 807e014..94385f0 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extbase\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\LinkHandling\LinkService;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileInterface;
 use TYPO3\CMS\Core\Resource\FileReference;
@@ -154,6 +155,11 @@ class ImageService implements \TYPO3\CMS\Core\SingletonInterface
             } else {
                 $image = $this->resourceFactory->getFileObject($src);
             }
+        } elseif (strpos($src, 't3://file') === 0) {
+            // We have a t3://file link to a file in FAL
+            $linkService = GeneralUtility::makeInstance(LinkService::class);
+            $data = $linkService->resolveByStringRepresentation($src);
+            $image = $data['file'];
         } else {
             // We have a combined identifier or legacy (storage 0) path
             $image = $this->resourceFactory->retrieveFileOrFolderObject($src);