Jeppe Donslund
Jeppe Donslund

Reputation: 503

Image in TYPO3 Fluid is not shown, gives error

I need to show an image in frontend.

<div class="col-md-12">
    <f:debug>{user.image.0}</f:debug>
    <f:if condition="{user.image}">
        <f:then>
            <f:image image="{user.image.0}" width="100" alt="" />
        </f:then>
        <f:else>
        </f:else>
    </f:if>
</div>

Debug of user.image gives this

TYPO3\CMS\Extbase\Domain\Model\FileReferenceprototypepersistent entity (uid=34, pid=8)    
uidLocal         => protected 16 (integer)   
originalResource => protected NULL    
uid              => protected 34 (integer)   
_localizedUid    => protected 34 (integer) modified   
_languageUid     => protected  0 (integer) modified  
_versionedUid    => protected 34 (integer) modified   
pid              => protected  8 (integer)

But in frontend I get this error

1476107295: PHP Catchable Fatal Error: Object of class TYPO3\CMS\Extbase\Persistence\ObjectStorage could not be converted to string in

I have tried to use both image=" and src=" but nothing works.

Does it have anything to do with GraphicsMagick not being installed on the server?

Upvotes: 0

Views: 888

Answers (1)

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10800

The reason for your problem probably is the usage of {user.image.0}.
While in earlier versions of fluid you could find the first image of an array in this way, in newer versions the array needs another handling:

<f:for each="{user.image}" as="userimage" iteration="iterator">
    <f:if condition="{iterator.isFirst}"><f:image image="{userimage}" width="100" alt="" /></f:if>
</f:for>

Upvotes: 0

Related Questions