0

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?

Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
Jeppe Donslund
  • 469
  • 9
  • 25

1 Answers1

0

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>
Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
  • The behavior/possibility came back in TYPO3 v9.5: https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/9.5.x/Important-87028-AccessObjectsFromObjectStorageUsingNumericValue.html – Julian Hofmann Mar 17 '21 at 14:59