You need to sign in to do that
Don't have an account?
Jacob.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:
When 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:
If I put the SignatureID in the url, it does load:
One 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
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:
When 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:
If I put the SignatureID in the url, it does load:
One 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
Sorry for this issue you are encountering.
May I suggest you please check with below link from the community forums which might help you.
- https://salesforce.stackexchange.com/questions/187424/display-image-which-is-stored-in-files
Please let us know if this helps.Thanks,
Nagendra