+ Start a Discussion
SteveAtGFISteveAtGFI 

Issue with using a controller for a dynamically generated image

I have several images stored in a zip file. I'm passing in a parameter to decide which one to display. Yet, I can't seem to get this to work:

 

<img alt="Chat Support" class="ssg-image-alignright" src="{!URLFOR($Resource.CSSimages, "{!Logo}")}" />

 

{!Logo} is the name of my image. i.e.:

 

MyImage.png.

 

The error I get is:

 

Description	Resource	Path	Location	Type
Save error: Element type "img" must be followed by either attribute specifications, ">" or "/>".	sc_kbsearch.component	/Sandbox/src/components	line 0	Force.com save problem

 Is there a way to get this to work the way I want? 

Rahul SharmaRahul Sharma

Hello Steve,

the string seems to be unterminated.

try this:

<img alt="Chat Support" class="ssg-image-alignright" src="{!URLFOR($Resource.CSSimages, '{!Logo}')}" />

or

<img alt="Chat Support" class="ssg-image-alignright" src="{!URLFOR($Resource.CSSimages, \"{!Logo}\")}" />
metaforcemetaforce

Rahul's solution should work perfectly because the outer double quotes are conflicting with the inner double quotes, so either:

 

1. the outer double quotes should be replaced with single quotes, or

 

2. the inner double quotes should be replaced with single quotes, or


3. the inner double quotes should be escaped

 

Do confirm if that solves the problem!