Permalink
Browse files

[BUGFIX] Fix image rendering for renderMethod = table

Since the introduction of FAL to TYPO3, the rendering of images
using CSS styled content with renderMethod = table is broken.

Using a single image results in the image being rendered twice
and if you have multiple images in one content object, only the
last image is rendered multiple times (depending on the amount
of images in the content object).

This patch resolves both issues and loads the current image file
reference to the contentObjectRenderer while looping through the
images of the content object.

Resolves: #46864
Related: #47004
Releases: master, 6.2
Change-Id: If120267111e30de6438cecc5e14cea34bc6fa235
Reviewed-on: http://review.typo3.org/35407
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
  • Loading branch information...
derhansen authored and wouter90 committed Dec 14, 2014
1 parent a84ec66 commit bce5ae7b988ec2fb658b49a93db946b1ed6e4fd2
Showing with 17 additions and 1 deletion.
  1. +17 −1 typo3/sysext/frontend/Classes/ContentObject/ImageTextContentObject.php
@@ -37,7 +37,7 @@ public function render($conf = array()) {
}
$imgList = isset($conf['imgList.']) ? trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.'])) : trim($conf['imgList']);
if ($imgList) {
$imgs = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $imgList);
$imgs = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $imgList, TRUE);
$imgStart = isset($conf['imgStart.']) ? (int)$this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.']) : (int)$conf['imgStart'];
$imgCount = count($imgs) - $imgStart;
$imgMax = isset($conf['imgMax.']) ? (int)$this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.']) : (int)$conf['imgMax'];
@@ -182,6 +182,9 @@ public function render($conf = array()) {
$GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
$GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
$imgKey = $a + $imgStart;
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($imgs[$imgKey])) {
$this->setCurrentFileInContentObjectRenderer(intval($imgs[$imgKey]));
}
$totalImagePath = $imgPath . $imgs[$imgKey];
$this->cObj->data[$this->cObj->currentValKey] = $totalImagePath;
$imgObjNum = (int)$splitArr[$a]['imgObjNum'];
@@ -469,4 +472,17 @@ public function render($conf = array()) {
return $output;
}
/**
* Loads the file reference object and sets it in the
* currentFile property of the ContentObjectRenderer.
*
* This makes the file data available during image rendering.
*
* @param int $fileUid The UID of the file reference that should be loaded.
* @return void
*/
protected function setCurrentFileInContentObjectRenderer($fileUid) {
$imageFile = $this->fileFactory->getFileReferenceObject($fileUid);
$this->cObj->setCurrentFile($imageFile);
}
}

0 comments on commit bce5ae7

Please sign in to comment.