Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I am trying to preview an apex:image in a visualforce page, which is going to be specified among this apex variable and taken from the static resources.

Here is my code

public sObject Object_A {set; get;}
Object_A = [SELECT Icon__c, ........];

Visualforce code

<apex:image url="{!URLFOR($Resource.Apex_Icons,'{!Object_A.Icon__c}.png')}"/>

But in this way I cant't get what is Object_A.Icon__c contains, instead of that I got an image that's named {!Object_A.Icon__c}.png

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

You are already in a Visualforce expression because of the outer url="{! ... }" so should able to use simple string concatenation:

<apex:image url="{! URLFOR($Resource.Apex_Icons, Object_A.Icon__c + '.png') }"/>
share|improve this answer
    
THANK YOU @keith-c –  Hasan Khatib Mar 30 at 17:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.