6

I'm utilizing the following URL to load an image stored as a ContentVersion file in an IMG tag. It loads correctly in SF but not on the force.com public site:

/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=06815000002QhYPAA0

I've tried loading the full URL path in the browser as well https://SITENAME.secure.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=06815000002QhYPAA0

Any suggestions?

UPDATE: I created the following sample VF page to exclude any other possibilities, the image loads correctly in SF, but when I try at the site URL it fails https://SITENAME.secure.force.com/apex/testcontent. Seems like its accessible but not rendering for some reason.

VF PAGE

<<apex:page controller="ctl_testContent" >
  <!-- attempt 1 -->
  <img src="/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId=06815000002QhYPAA0"/>

 <!-- test accessible -->
 {!cv.id}<br/>
 {!cv.versionData}
 </apex:page>

CONTROLLER:

public class Ctl_Testcontent {

public ContentVersion cv {get;set;}

public ctl_testContent() {
    cv = [SELECT Id,VersionData FROM ContentVersion WHERE id='06815000002QhYPAA0'];
}
}

OUTPUT:

[broken image]
06815000002QhYPAA0
core.filemanager.FileBlobValue@4bec7a37

UPDATE 2: As an update to this I noticed documents are very easy to make public via /servlet/servlet.ImageServer?id={DOCUMENT_ID}&oid={ORG_ID}. It'd be nice if there was something similar for SF Files. At this point I may have to clone SF Files to be Documents simply for this functionality. I have gotten SF Files to render in public sites but its a headache of creating a group, adding the public sites user, creating a library, adding a file to the library etc...not going to work for my use case where its automated.

8
  • Is the file accessible by the guest user? If it's in content, you can add the guest user to a public group and then share that file with the group.
    – Ryan Guest
    Commented Apr 6, 2017 at 5:58
  • @RyanGuest the file is set to viewable for all users in company and any users with link. We're not using content, just files if that makes sense. Is sharing via group the only option to make it accessible to render? The page has the correct contentversion ID so its getting the record, just won't render it.
    – Phil B
    Commented Apr 7, 2017 at 13:40
  • Does your site have a path prefix? i.e. is the home page: SITENAME.secure.force.com or SITENAME.secure.force.com/mysite
    – Ryan Guest
    Commented Apr 7, 2017 at 14:21
  • @RyanGuest it does not
    – Phil B
    Commented Apr 7, 2017 at 20:10
  • Have you tried /sfc/servlet.shepherd/servlet.shepherd/version/download/06815000002QhYPAA0
    – Mahmood
    Commented Apr 7, 2017 at 20:30

1 Answer 1

0

I faced this now too and after ....

  1. adding the guest user to a public group
  2. creating a public library and then adding the file to that library

If I use

<img style="max-width: 100%;" src="/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId={!ContentVersionId}"/> 

it doesn't work but if I use

<img style="max-width: 100%;" src="https://XXXX--YYYY--c.INSTANCE.content.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=THUMB720BY480&versionId={!ContentVersionId}"/>

then it works.

Compare your /apex version of the visualforce (right click on the image and open link) with the site.com URL and you will see there's a small difference.

You must log in to answer this question.

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