Chi*_*Chi 0 php typo3 fluid extbase
对于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.
任何提示?
最近在TYPO3 7.6.0中添加absolute了f:uri.image视图助手的参数.查看更改日志:
功能:#64286 - 为uri.image和图像viewHelper添加了绝对URL选项
ImageViewhelper和Uri/ImageViewHelper获得了一个绝对的新选项.使用此选项,您可以强制ViewHelpers输出绝对URL.
我建议升级到TYPO3 7.6.
如果您因任何原因无法做到这一点,可以扩展f:uri.image视图助手.下面的代码是未经测试的,但应该适用于6.2 LTS(我从TYPO3\CMS\Extbase\Service\ImageService7.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;
    }
}
| 归档时间: | 
 | 
| 查看次数: | 1586 次 | 
| 最近记录: |