TYPO3: get path out of file reference in Extbase

Deadly 提交于 2019-12-10 16:43:54

问题


i've created a Custom Content Element with Fluid and Extbase (TYPO3 6.1), in which you can define a picture. In the picture-settings i can set a img-link, which is targetting a file.

In my Controller i can access this data with

$this->configurationManager->getContentObject();

But i just get a file-reference for this setting and no path. like this:

file:1206

I've googled a lot and i didn't find a solution to access the path. Has anybody a solution or knows maybe a function in the configurationmanager or something else? I've spend hours on this problem...

Thanks a lot!


回答1:


What you have there, is a file reference of FAL, the file abstraction layer.

First things first, if you use FlexForms in combination with ActionController (or any realisation of AbstractController) you should be able to access the settings property to compute your FlexForm values.

To compute sys_file_reference records, you should refer to the FAL docs on typo3.org (and the perma-linked section about file and folder handling).

In general, you should be able to call getOriginalResource() on a \TYPO3\CMS\Extbase\Domain\Model\FileReference object. For more concrete examples, either refer to the doc links or have a look at the wiki for a example handling FileReferences.

If you want to compute such reference via fluid templating, you can use the treatIdAsReference argument on f:image:

<f:image src="{imageObj.uid}" width="150" height="100" treatIdAsReference="1" />




回答2:


If you need to get image from FAL than use following image view helper

<f:image src="{object.image_field.uid}" alt="{object.image_field.originalResource.title}" width="640" height="291" treatIdAsReference="1" />

If you just need url of image than use following line

{object.image.originalResource.publicUrl}..

Hurray.




回答3:


He is asking for a path and not for an image. This prints the path in fluid templates:

{f:uri.image(src:'{object.uid}',treatIdAsReference:'1')}


来源:https://stackoverflow.com/questions/18210635/typo3-get-path-out-of-file-reference-in-extbase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!