How can I display an image which is stored in files?

For attachments I can use the code below, but it doen't work for files.

<apex:image id="Stat1" URL="/servlet/servlet.FileDownload?file=0698E0000008w5e" width="15" height="15"/>
  • I am afraid that this can be done, there is a similar question with no answer. For Attachment the URL can be hard-coded or can be retrieved from $Action variable. As for Files, its not possible to preview it, but maybe hardcode URL to download it. – Raul Aug 7 '17 at 8:59
up vote 4 down vote accepted

Try this format <apex:image url="/sfc/servlet.shepherd/version/download/[DOWNLOADID]"/>.

How to get the DOWNLOADID?

Open the File, you will get a screen as below. Hover on the download link, you will get the DOWNLOADID as highlighted. Replace [DOWNLOADID] with the ID of the ContentVersion record you want to display.


<apex:image url="/sfc/servlet.shepherd/version/download/068i0000003ebfw"/>

enter image description here

VF Page :

<apex:page standardController="Account" >
    <apex:image url="/sfc/servlet.shepherd/version/download/0680H0000036GIH"/>


enter image description here

  • This would allow an user to download file instead of a preview. – Raul Aug 7 '17 at 9:39
  • @Rahul My bad. Please find the updated answer, I somehow didn't notice that the ContentVersion ID is not exactly same as the DownloadID as explained in my answer. Thanks for the observation :) – Saroj Bera Aug 7 '17 at 11:29

I've tried the solutions above with no success after few tries managed to view the image stored on files in my lightning component with similar url:

/sfc/servlet.shepherd/document/download/<YOUR FILE ID>

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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