Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
[Bugfix] take care of absRefPrefix for images
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbochmann committed Jul 24, 2018
1 parent b4c7507 commit 00818a8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Classes/Controller/ImageRenderingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use TYPO3\CMS\Core\Resource;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Service\ImageService;

/**
* Render the image attributes and reconstruct magic images, if necessary (and possible)
Expand Down Expand Up @@ -76,6 +77,7 @@ public function renderImageAttributes($content = '', $conf)
if ($fileUid) {
try {
$file = Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
$imageService = new ImageService();
if ($imageAttributes['src'] !== $file->getPublicUrl()) {
// Source file is a processed image
$imageConfiguration = [
Expand All @@ -84,21 +86,25 @@ public function renderImageAttributes($content = '', $conf)
];
$processedFile = $this->getMagicImageService()->createMagicImage($file, $imageConfiguration);
$additionalAttributes = [
'src' => $processedFile->getPublicUrl(),
'src' => $imageService->getImageUri($processedFile),
'title' => $imageAttributes['title'] ?: $file->getProperty('title'),
'alt' => $imageAttributes['alt'] ?: $file->getProperty('alternative'),
'width' => $processedFile->getProperty('width'),
'height' => $processedFile->getProperty('height'),
];
$imageAttributes = array_merge($imageAttributes, $additionalAttributes);
} else {
$imageAttributes['src'] = $imageService->getImageUri($file);
}
} catch (Resource\Exception\FileDoesNotExistException $fileDoesNotExistException) {
// Log the fact the file could not be retrieved.
$message = sprintf('I could not find file with uid "%s"', $fileUid);
$this->getLogger()->error($message);
}
}

}

return '<img ' . GeneralUtility::implodeAttributes($imageAttributes, true, true) . ' />';
}

Expand Down

0 comments on commit 00818a8

Please sign in to comment.