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
Michael Clarke 16Michael Clarke 16 

How do you create an image formula field in Lightning with Files (now Documents tab has disappeared)

Hi, there are many posts showing how to create formula fields for images and refer to the image in the Documents tab. In Lightning we have Files tab and not Documents tab. How do you get the image URL?
Best Answer chosen by Michael Clarke 16
AlibabaAlibaba
Easier solution - no SOQL involved. Simply copy the relative link of the image form the graphics pack to the image fomula, stripping out server name of course. For instance, 

IMAGE( "/resource/1565740474000/GraphicsPackNew/fatcow/farmfresh/16/exclamation.png",......)

All Answers

NagendraNagendra (Salesforce Developers) 
Hi Michael,

Sorry for this issue you are encountering.

It's an image permissions thing - go to Files, Clicked on the down arrow next to each image, selected 'Sharing Settings'  and change the Permissions of "Any user in your Company" from 'No Access' to 'Viewers'.

For more information please check with below link.
Please let us know if you need any further assistance.

Thanks,
Nagendra
Jainam ContractorJainam Contractor
Hi Michael,

To get the IMAGE from file using IMAGE formula field in Lightning you need to use the below URL pattern
IMAGE("/sfc/servlet.shepherd/version/download/ContentVersionId","", 100, 200)
The Image which is stored in file are stored as a ContentDocument and then after you need to fetch the VersionId of the ContentDocument which you can use in the above IMAGE formula. SOQL for fetching ContentVersionId is :
SELECT Id,Title FROM ContentVersion WHERE ContentDocumentId = 'ContentDocumentId/ FileId'
Please let me know if you need any more assistance.

Please mark it as the solution if it solved your purpose.

Thanks,
Jainam Contractor,
Salesforce Consultant,
Varasi LLC
www.varasi.com

 
AlibabaAlibaba
Easier solution - no SOQL involved. Simply copy the relative link of the image form the graphics pack to the image fomula, stripping out server name of course. For instance, 

IMAGE( "/resource/1565740474000/GraphicsPackNew/fatcow/farmfresh/16/exclamation.png",......)
This was selected as the best answer
Shruti DhingraShruti Dhingra
Hi Jainam, 
Can you please help me that how can we refer 

IMAGE("/sfc/servlet.shepherd/version/download/ContentVersionId","", 100, 200)

into our lightening page . I'm able to view the whole link on page but image is not coming there.

Thanks 
John Sadler 8John Sadler 8
Hi folks ... here is the best solution that is really simple. Until I found this, I just wasn't getting anything to work

https://help.salesforce.com/articleView?id=000327122&type=1&mode=1

The most salient point is this:
Obtain the URL to the image files uploaded:
In Files, Click an image to view the image preview.
Right click the image, then select Copy image address (could be Copy Image Location).
Save this image URL so you don't lose it.
You only need the part of the url that begins with /sfc/servlet.shepherd
Example URLs:
"/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=06846000002mPro&operationContext=CHATTER&contentId=05T46000009hQHt/image.jpg"
"/sfc/servlet.shepherd/version/download/06846000002mPro"

So here's a sample formula suing part of the image URL
IMAGE("/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=0680I00000I3uyX&operationContext=CHATTER&contentId=05T0I00000rsVoW", "Logo", 30, 100)