4

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!

Daniel
  • 6,916
  • 2
  • 36
  • 47
Hayo
  • 240
  • 1
  • 2
  • 12

3 Answers3

15

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.

Vivek Parmar
  • 773
  • 1
  • 10
  • 26
10

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

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49
Cedric Ziel
  • 1,052
  • 8
  • 21
  • 2
    I would recommend using the provided `image` property, instead of parsing the uid through the src attribute. So `` – YeppThat'sMe Mar 13 '15 at 16:04
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')}
Christian Michael
  • 2,128
  • 1
  • 19
  • 27
  • Thats what he is asking for, but not, what he is actually trying to achive. People are like that sometimes. – j4k3 Nov 01 '17 at 18:24
  • @j4k3 Sure ... me too. But the google search is stupid and just looks for words. Maybe someone will find that page and is looking for what he is asking for and wants to achive exactly what he is asking for in the headline ... like me before I found the answer elserwhere ... than there is no need to look elsewhere :-) – Christian Michael Nov 02 '17 at 20:37