Another Salesforce blog!!!

Salesforce, Apex

static resources in Visualforce

CSS File:

<apex:stylesheet value="{!URLFOR($Resource.style_resources, 'styles.css')}"/>

Relative path in CSS from static resource, You can use relative paths in files in static resource archives to refer to other content within the archive.

table { background-image: img/testimage.gif }

Image tag:

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


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

Include Javascript in Visualforce from Static resource

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

Refer static resource path from Aprx Controller

global class MyController {
    public String getImageName() {
        return 'Picture.gif';//this is the name of the image

view sourceprint?

<apex:page renderAs="pdf" controller="MyController">
    <apex:variable var="imageVar" value="{!imageName}"/>
    <apex:image url="{!URLFOR($Resource.myZipFile, imageVar)}"/>

Leave a Reply

Your email address will not be published. Required fields are marked *