[TYPO3-mvc] imageViewHelper: "Could not get image resource for ..."

Thomas "Thasmo" Deinhamer thasmo at gmail.com
Sun May 30 22:33:10 CEST 2010


Am 30.05.2010 21:01, schrieb Henjo Hoeksma:
> On 2010-05-30 17:28:56 +0200, Henjo Hoeksma said:
>
>> Hi list,
>>
>> I am new to ExtBase / Fluid and am intrigued :-)
>>
>> I run into a fluid issue though when trying to use images. I get the
>> error: "Could not get image resource for " followed by the filename.
>>
>> My Fluid looks like this:
>> <f:image src="{product.image}" width="50" alt="{product.name}" />
>>
>> My Model uses:
>> /**
>> * Image of the product
>> * @var string
>> */
>> protected $image;
>>
>> What am I missing?
>>
>> Is there a way to provide a 'if no file show custom error msg' option?
>>
>> Thanks!
>>
>> Henjo
>
> Hi,
>
> the first part I figured out - thanks to your help Franz en Martin.
>
> What about the second question:
>
> Is there a way to provide a 'if no file show custom error msg' option?
>
> Thanks!
>
> Henjo
>

To check if a file exists I wrote my own viewHelper which then can be 
used (basically) like this:

<f:if condition="{my:file.exists(path: '{image}')}">
	<f:image ... />
</f:if>

You could also write your own image viewHelper to which you could 
provide an error message or a default image:

<my:image src="" fallback="" errorMessage="" />

Regards,
Thomas


More information about the TYPO3-project-typo3v4mvc mailing list