How to use Static Resources in Visualforce Pages Salesforce

by Rijwan Mohmmed
3 read
how-to-use-static-resources-in-visualforce-pages-salesforce

Hello folks, today we will discuss How to use Static Resources in Visualforce Pages Salesforce. Generally, the static resource can contain a single file or an archive like .zip or .jar. so there are two ways to get static resources.

  1. If the static resource is a single file.

Use $Resource.name_of_resource as a merge field. So after the $Resource. write the name of the static resource you want to use.

<apex:image url="{!$Resource.TestImage}" width="50" height="50"/>

2. If the static resource is a zip of the folder containing multiple files.

To reference a file in an archive, use the URLFOR function. Specify the static resource name that you provided when you uploaded the archive with the first parameter and the path to the desired file within the archive with the second.

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

What’s your Reaction?
+1
1
+1
1
+1
0
+1
0
+1
0
+1
0

You may also like

Leave a Comment