Commit 0992608f authored by Andreas Wolf's avatar Andreas Wolf Committed by Thomas Löffler
Browse files

[CLEANUP] Remove dependency to image view helper in t3o_ajaxlogin

Change-Id: Ib90d008ecbb95857ec268fc8f91e29aacfa79a33
Reviewed-on: https://review.typo3.org/50619

Reviewed-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
Tested-by: Thomas Löffler's avatarThomas Löffler <loeffler@spooner-web.de>
parent 69eff8b8
<?php
class Tx_TerFe2_ViewHelpers_UserImageViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper
{
/**
* @param \TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user
* @param string $size
* @param string $width
* @param string $height
*
* @throws Tx_Fluid_Core_ViewHelper_Exception
* @return string image HTML code
*/
public function render(\TYPO3\CMS\Extbase\Domain\Model\FrontendUser $user, $size = 'big', $width = '', $height = '')
{
if (!is_callable(array($user, 'getUserImageHash'))) {
return '';
}
if ($size !== 'big' && $size !== 'mid' && $size !== 'small') {
return '';
}
$userImageHash = $user->getUserImageHash();
if (empty($userImageHash)) {
return '';
}
if (TYPO3_MODE === 'BE') {
\TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::simulateFrontendEnvironment($this->getContentObject());
}
$src = 'uploads/tx_t3ouserimage/' . $userImageHash . '-' . $size . '.jpg';
$setup = array(
'width' => $width,
'height' => $height,
);
$imageInfo = $this->getContentObject()->getImgResource($src, $setup);
$GLOBALS['TSFE']->lastImageInfo = $imageInfo;
if (!is_array($imageInfo)) {
return '';
}
$imageInfo[3] = \TYPO3\CMS\Core\Imaging\GraphicalFunctions::pngToGifByImagemagick($imageInfo[3]);
$GLOBALS['TSFE']->imagesOnPage[] = $imageInfo[3];
$imageSource = $GLOBALS['TSFE']->absRefPrefix . \TYPO3\CMS\Core\Utility\GeneralUtility::rawUrlEncodeFP($imageInfo[3]);
if (TYPO3_MODE === 'BE') {
$imageSource = '../' . $imageSource;
\TYPO3\CMS\Extbase\Utility\FrontendSimulatorUtility::resetFrontendEnvironment();
}
$this->tag->addAttribute('src', $imageSource);
$this->tag->addAttribute('width', $imageInfo[0]);
$this->tag->addAttribute('height', $imageInfo[1]);
if ($this->arguments['title'] === '') {
$this->tag->addAttribute('title', $this->arguments['alt']);
}
return $this->tag->render();
}
/**
* @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
private function getContentObject()
{
/** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $TSFE */
$TSFE = $GLOBALS['TSFE'];
return $TSFE->cObj;
}
}
?>
\ No newline at end of file
{namespace terfe2=Tx_TerFe2_ViewHelpers}
{namespace userimage=Tx_T3oAjaxlogin_ViewHelpers}
<div class="ter-ext-single-info ter-ext-info">
<table>
......@@ -122,7 +121,7 @@
<td>
{owner.name}
<br />
<userimage:userImage user="{owner}" alt="{owner.name}" size="mid" />
<terfe2:userImage user="{owner}" alt="{owner.name}" size="mid" />
</td>
</tr>
</f:if>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment