function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EIE50EIE50 

Basic Static resource in <img> question

Hi,

 

I know this is a silly question, but i am not able to see the image when i call a static resource image in to visualforce using <img> tag. This is what i am using right now, and the picture is not appearing in the VF Page,  i just see a cross mark instead of the picture.

 

<img src="{ !$Resource.image_TwitterIcon }" />

 

I have the above individual picture  in static resources. Can any one suggest a way to fix this.

 

Thanks.

blombardisblombardis

Hi,

 

I think you should write

 

<img src="{!URLFOR($Resource.image_TwitterIcon)}" />

 

Hope this helps you,

Bruno

EIE50EIE50

Hi,

 

I ve already tried this and it did not help. I get the same X mark instead on the picture.

 

Thanks.

blombardisblombardis

Static Resources

Upload static resources, such as stylesheets and images, into a zip, and then reference
them using the URLFOR formula and $Resource merge field. For example, if you've
uploaded images/Blue.jpg into a zip called TestZip, reference it like this:
<apex:image url="{!URLFOR($Resource.TestZip,'images/Blue.jpg')}"/>

 

Here is part of the documentation for Static resources. 

 

Static ResourcesUpload static resources, such as stylesheets and images, into a zip, and then referencethem using the URLFOR formula and $Resource merge field.

 

For example, if you'veuploaded images/Blue.jpg into a zip called TestZip, reference it like this:

 

<apex:image url="{!URLFOR($Resource.TestZip,'images/Blue.jpg')}"/>

 

For more info:

http://www.salesforce.com/us/developer/docs/pages/index.htm

 

Bruno

KevinBrKevinBr

Another approach, is to upload each image as a document, then mark it as externally available.
You can then leverage custom settings (ie, Public, Hiearchy) to point to those urls.

The url consists of 3 parts:
force.com domain
id is the image Id (015*)
oid is the org Id (00D*)
https://c.na#.content.force.com/servlet/servlet.ImageServer?id=###p&oid=###

If you use prod as your source, be mindful on refreshes that the oid values can get reset in the settings to the current sandbox org id.

Then, you can create a custom formula that works as an image in a page or list view:
IMAGE($Setup.My_Custom_Settings__c.extMail__c,'New Mail'),

These external images can then also be used in email templates as well.