Pages

Friday, March 12, 2021

Adding Image to Salesforce

Adding Image to the Lightning page

This is actually pretty simple:

  • add a Rich Text component in Lightning App Builder
  • copy the image from a browser
  • paste into the Rich Text component 
Bonus point, since this is a component, you can make use of "Set Component Visibility" to show/hide the Rich Text component based on the record field value or device or user detail or permission. Also, can use filter logic to show/hide the component.

In the rich text component, you can combine this formatted text and additional images.



Adding Image to Page Layout

Salesforce does not have a field with the type = image, however, we can make use formula field return text with the Image() formula. 

IMAGE(image URL, alternate text [, height, width])

You can enter any URL into the image URL, such as: 
IMAGE("https://1.bp.blogspot.com/-47gF2_GhWPI/YETO_7zJZlI/AAAAAAAALRs/LfNRxwKvq3U7GeJXuu4d9HG2pzUjAPAZwCLcBGAsYHQ/w400-h100/sc%2Butf8.png", "Hello", 157, 627)



or simply populate the Image URL and alternate text for the parameter
IMAGE("https://1.bp.blogspot.com/-47gF2_GhWPI/YETO_7zJZlI/AAAAAAAALRs/LfNRxwKvq3U7GeJXuu4d9HG2pzUjAPAZwCLcBGAsYHQ/w400-h100/sc%2Butf8.png","Hello")



However, the above image is public or depends on external storage. We can make use of the Salesforce library to store the images, check out this article


Static Resources
Another option is to load the image as Static Resources.

IMAGE("/resource/This_is_image", "Hello")



Since this is a formula field, you can make use of IF() function to determine which image to show based on the criteria.


FREE Images Components 📷 by SharinPix

FREE Images Components 📷 by SharinPix is a native Salesforce picture management based on Salesforce images capabilities. Use the components to display images on a record page. Choose from a banner format, photo album, slideshow or a slider. You can even upload images from the components as well!

Check out this component from AppExchange, or the paid version Image/Photo Management for Salesforce for more features.




No comments:

Post a Comment

Page-level ad