$Resource

A global merge field type to use when referencing an existing static resource by name in a Visualforce page. You can also use resource merge fields in URLFOR functions to reference a particular file in a static resource archive.

Usage

Use {!$Resource} to reference an existing static resource. The format is {!$Resource.nameOfResource}, such as {!$Resource.TestImage}.

Examples

The Visualforce component below references an image file that was uploaded as a static resource and given the name TestImage:
<apex:image url="{!$Resource.TestImage}" width="50" height="50"/>
To reference a file in an archive (such as a .zip or .jar file), 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. For example:
<apex:image url="{!URLFOR($Resource.TestZip,
                  'images/Bluehills.jpg')}" width="50" height="50"/>

You can also use dynamic references to reference static resources. For example, {!$Resource[appLogo]}, assuming there is an appLogo property or getAppLogo() method in your page’s controller.

See Also