Search code examples
imagetypo3fluidtx-dce

Typo3 DCE Images


I'll try to design my own content elements with DCE (Dynamic Content Elements). The problem I have a problem when I try to work with images. I created a select field for images which works fine. In the fluid template I have the following code for handling the image:

<f:image src="{field.image}" alt="" treatIdAsReference="1" />

But if I try to insert the content element, Typo3 throws me this exeption:

Oops, an error occurred!

No file usage (sys_file_reference) found for given UID.

More information regarding this error might be available online.

I already found out, that this is pretty sure a bug in Typo3, but how can I fix it?


Solution

  • Got it. With the hint form vijay rami I found out, that you have to render images in dce like this:

    <f:for each="{dce:fal(field:'image', contentObject:contentObject)}" as="fileReference" iteration="iterator">
        <f:if condition="{iterator.isFirst}">
            <f:image src="{fileReference.uid}" alt="" treatIdAsReference="1" />
        </f:if>
    </f:for>
    

    Of course you have to edit in the first line "field:'image'" to your name.