3

I have a static resource which is a zip file of images which i am accessing in my VF page which is a part of managed package. I want to have an ability of letting the installed org have their own images as it would be different for different organizations.

Anybody having thoughts on how this can be achieved. or if at all it can be achieved.

1 Answer 1

2

Since Spring '12 it has been possible to reference a static resource dynamically using this syntax:

{!$Resource[name]}

So create a public custom setting that has a field for the name of each image and make the default value for each field match the name of the default image in your managed package (may require namespace prefix). Then (assuming the setting is made available via a field called "cs" in the controller) change the references in the Visualforce pages to this form:

{!$Resource[cs.XyzImageName__c]}

Then after deployment you can manage the custom setting to use the names of the locally added image static resources.

1
  • Is there some trick to getting this to work with Managed Packages? I have a package that uses the reference you describe, and it works great when I reference a static resource included in my package in a target org - but if I load one locally into that org, the package can't find it? The only difference I can see is that I am storing the name in a field on a Campaign record, rather than in a C/S but not sure why that would affect it? Commented Jul 23, 2014 at 16:00

You must log in to answer this question.

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