I've been doing this:


to reference from a visual force page a static resource inside a zip file, there are some files 0.jpg, 1.jpg, etc. at the top level of the zip file but is beyond me why is not working (by this I mean, the image is not showing in the page). If someone can enlighten me about it, I would appreciate.


I have a page construct as this:

<apex:page standardController="Contact" docType="html-5.0" standardStylesheets="false" cache="true" applyBodyTag="false" recordSetVar="contacts" extensions="Some_Ext">
        <apex:styleSheet value="{!$Resource.style}"/>
            <apex:image value="{!URLFOR($Resource.resourcename, '0.jpg')}"/>


The problem was that the image was a .png not a .jpg as I was referencing in the VF Page.

¡Be completely sure of the path and file EXTENSION when referencing a Static Resource!

  • Are you 100% sure the files are in the top of the zip. I'm talking about situation where for resource "test" the archiving program created a folder "test" within the zip so you have to go {!URLFOR($Resource.test,'test/0.jpg')}
    – eyescream
    Commented May 21, 2014 at 22:40
  • 100% sure. Actually tried with several paths as 'folder/img.jp', '/folder/img.jp', 'img.jp', '/img.jp', and so on. @eyescream
    – Jose
    Commented May 21, 2014 at 22:56
  • your body tag is not closed fine so its throwing errors( hopefully u have it right in the page) I copy paste your code and the image renders with no issue. Unless the 0.jpg is not 0 and it is a character o i would be surprised why the image is not loading as you are.
    – Rao
    Commented May 21, 2014 at 22:57
  • Its fine in my page. Just fix the typo, its 0 as in the number 0. @rao
    – Jose
    Commented May 21, 2014 at 22:59
  • 1
    Any chance you can upload the zip (can contain just this 1 offending image) somewhere? Dropbox maybe? Does the browser's JS console report any errors like 404 file not found?
    – eyescream
    Commented May 21, 2014 at 23:00

2 Answers 2


Check this documentation


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. For example:

                  'images/Bluehills.jpg')}" width="50" height="50"/>

(OR) if 1 is too confusing save the CSS/ JS/ Image or be it anything as a seperate static resource and reference it in VF page as


I usually prefer the second method since I have never been comfortable with zip file and extending the path.


My ZIP file content:

enter image description here

The page saves even though u do not have the closing } bracket, check if you have formed the image tag and closed the { and } for the URLFOR function.

Make sure the syntax is correct for the image tag as well as the URLFOR.

enter image description here

<apex:page >
<apex:form >
<apex:image value="{!URLFOR($Resource.tezip, 'te.jpg')}" />

My output was :

![enter image description here][3]



enter image description here

  • Yeah, done that. Still not working. The second method works fine, but the idea is not to have so many resources.
    – Jose
    Commented May 21, 2014 at 22:19
  • @jose what is not working is the page not loading/ breaking/ not showing what you expect to see? can you paste your page and what you are trying
    – Rao
    Commented May 21, 2014 at 22:21
  • Is not showing the image, as if the path was incorrect.
    – Jose
    Commented May 21, 2014 at 22:23
  • can you try the path 2 where you save the image as a seperate static resource and reference it in a VF page since it s hard to say how the zip file is created etc.
    – Rao
    Commented May 21, 2014 at 22:24
  • Yes, right now I'm doing it like that and works but really want to know why the other option is not working.
    – Jose
    Commented May 21, 2014 at 22:32

Here is something else you may wish to try:

Go to the static resource 'Detail' page via the Salesforce menu and copy the link address from the 'View file' link into the address bar of your browser. The link should look something like:


If you were to go to this address then your browser would just download the resource, however you can experiment by appending to the url to get at files within the ZIP file. For example I can get to:


This renders application.js in my browser without needing to download any zip file. I find this a much quicker way to figure out the correct relative paths within my static resources.

In terms of finding the correct relative path (i.e. the second parameter to URLFOR) I would suggest downloading the static resource by clicking 'View file' on the static resource detail page and unzip the downloaded resource. Lets say that unzipping this results in a folder called "myResource" that contains a single file called "myImg.jpg", then I believe that the path should be:


And hence in your Visualforce page you would use:


This is a bit of a stab in the dark. I can only hope that it might help :-)

  • Also, I realise that some of the things I have mentioned have sort of already been mentioned in earlier comments. Commented May 21, 2014 at 23:12
  • When I downloaded it, it was just a folder with the Static Resource name (NOT ZIP, didn't have to unzip) and the files in it.
    – Jose
    Commented May 21, 2014 at 23:24
  • Interesting. A couple of questions, I presume it was definitely a ZIP file when you uploaded it? Also, what browser are you using? Commented May 21, 2014 at 23:40
  • Yes it was a zip, safari. Any how, found the problem - Check my question note.
    – Jose
    Commented May 21, 2014 at 23:59

You must log in to answer this question.

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