4

I am building a managed package which refers to a set of images. These images would vary from each installation to another. So i was thinking of allowing the users to upload a static resource in their environment and add that name in an object or custom setting and i use that static resource in my VF page in managed package.

I am unsure as to how to reference the loaded static resource in my VF page.

 <apex:image value="{!URLFOR($Resource.tweets, 'ppimages/tweets1.gif')}" style="padding-left:10px"/>

I want to replace tweets with a value from a record.

I have the value to be replace the 'tweets' in a controller variable called sResourceName.

 <apex:image value="{!URLFOR($Resource.sResourceName, 'ppimages/tweets1.gif')}" style="padding-left:10px"/>

This doesnt work as its trying to see if there is a static resource called sResourceName. Is there a way i can use the value in my controller variable to get the static resource?

2 Answers 2

2

Something like :

<img src="{!URLFOR($Resource.QCreditCards,'')}/{!item.card.ImageName__c}" width="64"/>
1
  • This is pretty much your best bet — use a merge field as part of the name. If you've got two resources just put them into one and use two directories inside the zip file.
    – Matt Lacey
    Commented Sep 13, 2013 at 9:11
1

The best way to do this is with a dynamic reference to a global variable. For example:

{!URLFOR($Resource[sResourceName], 'ppimages/tweets1.gif')}

Hope this helps!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .