absolute
爲f:uri.image
視圖助手的參數僅在最近TYPO3 7.6.0中添加。見changelog:
Feature: #64286 - Added absolute url option to uri.image and image viewHelper
The ImageViewhelper and Uri/ImageViewHelper got a new option absolute. With this option you are able to force the ViewHelpers to output an absolute url.
我建議升級到7.6 TYPO3。
如果由於任何原因您無法進行此操作,則可以擴展f:uri.image
視圖幫助程序。下面的代碼是未經測試,但應爲6.2 LTS(我借用TYPO3\CMS\Extbase\Service\ImageService
部分代碼在7.6)工作:
namespace Vendor\ExtensionKey\ViewHelpers\Uri;
use TYPO3\CMS\Fluid\ViewHelpers\Uri\ImageViewHelper;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class ImageViewHelper extends ImageViewHelper
{
public function render(
$src = null,
$image = null,
$width = null,
$height = null,
$minWidth = null,
$minHeight = null,
$maxWidth = null,
$maxHeight = null,
$treatIdAsReference = false,
$absolute = false
) {
$uri = parent::render($src, $image, $width, $height, $minWidth, $minHeight, $maxWidth, $maxHeight, $treatIdAsReference);
if ($absolute) {
$uriPrefix = $GLOBALS['TSFE']->absRefPrefix;
$uri = GeneralUtility::locationHeaderUrl($uriPrefix . $uri);
}
return $uri;
}
}
好的非常感謝你!不幸的是,更新不是一個選項,但我會實現你的擴展f:uri.image – Chi
@Chi,出於好奇,這個解決方案是否適合你?我的答案中有哪些可以改進? – helmbert
我實際上已經嘗試過你的解決方案 - 但在我的情況下,我無法讓視圖幫助器在Typo3 6.2中工作。 - 它甚至不會加載(參數「絕對」未註冊。) – fbtb