![](/img/trans.png)
[英]how to: display an image generated on the fly without writing it to disc - from a typo3 v4.5 extbase extension?
[英]TYPO3 (with extbase) fluid: display image src with absolute path
对于XML导出,我需要输出2张图像的绝对路径。 Image1位于/typo3conf/ext/app/Resources/Public/Images/image1.png,Image2位于/uploads/tx_extensionname/image2.png
对于我的一生,我找不到找到图像绝对路径的方法。 我试过的
<f:uri.image absolute="1" src="EXT:app/Resources/Public/Images/image1.png"/>
返回以下错误:
Argument "absolute" was not registered.
我也尝试了f:uri.resource,它适用于image1,但是当然不适用于image2,因为没有extensionName。
有什么提示吗?
f:uri.image
视图帮助器的absolute
参数是最近才在TYPO3 7.6.0中添加的。 请参阅更改日志 :
功能:#64286-向uri.image和image viewHelper添加了绝对URL选项
ImageViewhelper和Uri / ImageViewHelper获得了一个新的绝对选项。 使用此选项,您可以强制ViewHelpers输出绝对URL。
我建议升级到TYPO3 7.6 。
如果由于某种原因无法实现,则可以扩展f:uri.image
视图帮助器。 以下代码未经测试,但应适用于6.2 LTS(我从7.6中的TYPO3\\CMS\\Extbase\\Service\\ImageService
中借用了部分代码):
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;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.