[BUGFIX] Don't prepend absolute image URLs 86/32786/5
authorFranz Koch <typo3@elements-net.de>
Mon, 15 Sep 2014 16:15:20 +0000 (18:15 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Tue, 16 Sep 2014 11:08:46 +0000 (13:08 +0200)
The ImageService->getImageUri() method always prepends the public URL of
the image object with a prefix, regardless whether the object already
returns a fully qualified URL. This can be the case when the FAL driver
is connecting a remote image storage that doesn't allow local processing
and requires the images to be loaded from the remote server.

Change-Id: Iac65bc93bc0d1c1cbeb2335b7e13fc2126b728b6
Resolves: #61617
Releases: 6.2, 6.3
Reviewed-on: http://review.typo3.org/32786
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Franz Koch <typo3@elements-net.de>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Stefan Froemken <froemken@gmail.com>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/extbase/Classes/Service/ImageService.php

index 27448c8..3001076 100644 (file)
@@ -65,13 +65,18 @@ class ImageService implements \TYPO3\CMS\Core\SingletonInterface {
         * @api
         */
        public function getImageUri(FileInterface $image) {
-               if ($this->environmentService->isEnvironmentInFrontendMode()) {
+               $imageUrl = $image->getPublicUrl();
+
+               // no prefix in case of an already fully qualified URL (having a schema)
+               if (strpos($imageUrl, '://')) {
+                       $uriPrefix = '';
+               } elseif ($this->environmentService->isEnvironmentInFrontendMode()) {
                        $uriPrefix = $GLOBALS['TSFE']->absRefPrefix;
                } else {
                        $uriPrefix = '../';
                }
 
-               return $uriPrefix . $image->getPublicUrl();
+               return $uriPrefix . $imageUrl;
        }
 
        /**