function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jacob.MarshallJacob.Marshall 

Display image stored as a File in object layout

I'm currently in the process of updating an org's custom code to allow us to replace Attachments with Files.  We had a trigger that would previously save an image as an attachment, then use an embedded visualforce page on the layout to display that image.  I've successfully altered the code to save the image as a File, but need assistance in viewing the file in the layout.

The previous visualforce page to view attachments was this:
<apex:page standardcontroller="Medical_Information_Request__c" standardStylesheets="false" showHeader="false" sidebar="false">
    <img src="/servlet/servlet.FileDownload?file={!Medical_Information_Request__c.SignatureId__c}"/>
</apex:page>
SignatureId__c stored the Id of the attachment.  This img src url did not work for files, and I had temporary luck with viewing this image as a file with the following:
<apex:page standardcontroller="Medical_Information_Request__c" standardStylesheets="false" showHeader="false" sidebar="false">
    <img src="/sfc/servlet.shepherd/version/download/{!Medical_Information_Request__c.SignatureId__c}?asPdf=false"/>
</apex:page>
In the above, I'm saving the Id of the ContentVersion object that I saved.  I've also tried using the Id of the ContentDocument  Unfortunately, after a refresh when viewing the object page I get this error:
User-added imageWhen I try with the ContentDocument Id, the object's layout loads, but the image doesn't.

I can see the file is properly saved and it linked to the object correctly:
User-added image
If I put the SignatureID in the url, it does load:
User-added imageOne last curiousity, which might be a red herring, is that the download button on the file page gives a new Id that isn't the ContentDocument Id or the ContentVersion Id:
https://c.cs78.content.force.com/sfc/servlet.shepherd/version/download/0681k0000000FId?asPdf=false&operationContext=CHATTER
What object does this Id relate to?

I'd appreciate any assistance
NagendraNagendra (Salesforce Developers) 
Hi Jacob,

Sorry for this issue you are encountering.

May I suggest you please check with below link from the community forums which might help you. Please let us know if this helps.

Thanks,
Nagendra