Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3: get path out of file reference in Extbase

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!

like image 951
Hayo Avatar asked Nov 28 '22 11:11

Hayo


2 Answers

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.

like image 97
Vivek Parmar Avatar answered Dec 18 '22 21:12

Vivek Parmar


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" />

like image 44
Cedric Ziel Avatar answered Dec 18 '22 23:12

Cedric Ziel