0
votes

I use a PHP based view to return XML in an Extbase extension (TYPO3 6.2). All works great except for the path of images that needs to be included in the XML.

I use the following to get the file reference:

$user->addChild('event_image', $event->getPerformance()->getEventImage());

The output in XML is:

<event_image>TYPO3\CMS\Extbase\Domain\Model\FileReference:124</event_image>

When I try to get the URL path to the image with this code

$user->addChild('event_image', $event->getPerformance()->getEventImage()->getImage()->getOriginalResource()->getPublicUrl());

I get the following error message:

Fatal error: Call to undefined method TYPO3\CMS\Extbase\Domain\Model\FileReference::getImage()

My question: How can I get the URL path from the file reference?

2

2 Answers

1
votes

If you are not using a fluid template, take a closer look at typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php within your TYPO3 installation.

That's basically the function call as if you would use the f:uri.image fluid Viewhelper within your XML template:

<event_image><f:uri.image src="{event_image}" treatIdAsReference="1" /></event_image>
1
votes

There seems to be a typo in your code. The method is called getOriginalResource(), not getOriginalRecource().