2016-01-13 144 views
0

對於XML導出,我需要輸出2個圖像的絕對路徑。此搜索位於/typo3conf/ext/app/Resources/Public/Images/image1.png 和鏡像2位於/uploads/tx_extensionname/image2.pngTYPO3(含extbase)fluid:以絕對路徑顯示圖像src

對於我的生活,我不能找到一個辦法讓圖像的絕對路徑。我的嘗試:

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

它返回以下錯誤:

Argument "absolute" was not registered. 

我也試過F:uri.resource,該協會致力於此搜索,但是,當然,不用於圖像2,因爲有不是extensionName。

任何提示?

回答

4

absolutef: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; 
    } 
} 
+0

好的非常感謝你!不幸的是,更新不是一個選項,但我會實現你的擴展f:uri.image – Chi

+0

@Chi,出於好奇,這個解決方案是否適合你?我的答案中有哪些可以改進? – helmbert

+0

我實際上已經嘗試過你的解決方案 - 但在我的情況下,我無法讓視圖幫助器在Typo3 6.2中工作。 - 它甚至不會加載(參數「絕對」未註冊。) – fbtb