Currently, we have a feature in one of our products that allows you to upload an attachment to one of our objects to use as a thumbnail on the page it's displayed on. With attachments, I am able to build a URL that allows the site to grab that image for use, and everything works fine.

Because lightning will be doing away with attachments, switching instead to ContentDocuments, I thought I'd look into how to get them to work in a similar way. Unfortunately, I haven't been able to find a way to actually get a ContentDocument after getting it's Id. With Attachments, I could just use this url:

sitePrefix + '/servlet/servlet.FileDownload?file=' + attachment.Id

Is there a way to do something similar with ContentDocuments? It would suck pretty bad to tell our clients this just won't work anymore once SF decides to finally close access to attachments.

  • I can't upvote this question enough times. We ran into a similar issue trying to get documents from chatter and to my knowledge it has still not been solved.
    – gNerb
    Mar 23, 2017 at 15:07

1 Answer 1


I was having the same issue and frustration. But it looks like this is possible, I just wasnt searching correctly. There are answers out there going back 7+ years.

The key is to use ContentVersionID (ID with 068 prefix). On the ContentDocumentObject, this is the LatestPublishedVersionId. This is what I used within my Community:

 <img src="{!'/<<community name>>/sfc/servlet.shepherd/version/download/'+ContentVersionID }" />
  • Sorry I never responded to your answer, we moved this issue to a lower priority so I haven't had time to get back to it as I've been working on other things. If I ever do get a chance to come back to this issue, I'll try to remember to accept your answer. Thanks! Sep 28, 2017 at 14:41

You must log in to answer this question.

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