dongzhen7108 2016-01-13 13:45
浏览 17
已采纳

TYPO3(带有extbase)流体:用绝对路径显示图像src

For an XML Export I need to output the absolute path of 2 images. Image1 is located in /typo3conf/ext/app/Resources/Public/Images/image1.png and Image2 is located in /uploads/tx_extensionname/image2.png

For the life of me I cannot find a way to get the absolute paths of the images. What I tried:

<f:uri.image absolute="1" src="EXT:app/Resources/Public/Images/image1.png"/>

Which returns the following error:

Argument "absolute" was not registered.

I also tried f:uri.resource , which works for image1, but, of course, doesn't for image2 because there is no extensionName.

Any hints?

  • 写回答

1条回答 默认 最新

  • doujianguang5506 2016-01-13 14:13
    关注

    The absolute argument for the f:uri.image view helper was added only recently in TYPO3 7.6.0. See the 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.

    I'd suggest upgrading to TYPO3 7.6.

    If that's not possible for you for any reason, you can extend the f:uri.image view helper. The code below is untested, but should work for 6.2 LTS (I've borrowed parts of the code from TYPO3\CMS\Extbase\Service\ImageService in 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;
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵