I am accessing my static resource using apex:image

<apex:image url="https://test.salesforce.com{!$Resource.payment}" width="50" height="50"/>

When I take out the https://test.salesforce.com from the url the image does not show up. On inspecting without salesforce url it looks like the image is coming from some other site https://abc.xyz.com/resource/id/payment(cant disclose original url).

  • Why not using <apex:includeScript>?
    – Lance Shi
    Dec 23, 2016 at 6:22
  • @Lance didnot work either
    – deepak
    Dec 23, 2016 at 6:26

2 Answers 2


Try this.

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

More on referencing static resource in vf markup.

  • this is the first thing i tried it did not work
    – deepak
    Dec 23, 2016 at 9:01
  • What is MIME Type of your static resource payment
    – Reshma
    Dec 23, 2016 at 9:18
  • MIME Type image/jpeg
    – deepak
    Dec 23, 2016 at 9:24
  • Are you showing this image in a panel or pageblock something like that
    – Reshma
    Dec 23, 2016 at 9:33
  • no just showing it in html div
    – deepak
    Dec 23, 2016 at 9:34

Use URLFOR and ensure the access level of the Resource is set to public

<apex:image url="{!URLFOR($Resource.payment)}" width="50" height="50"/>

Which will resolve the complete URL regardless of where the page is accessed from, SF, Community, Site, etc

  • Did not work tried it already
    – deepak
    Dec 23, 2016 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.