Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 '14 at 17:42

Your Answer


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.