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://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf8aRfxLWfr0CQLooZltAZkJjucrOLoA13nE_-TGqy3Pwlf8yaXOV_zMubAY2XJv1qTmkX0-tnqAvr0za3Op2g3XQ4SF-ZNtW4NoRyFCB6rGzlXmbJaFM9QRS2RAt2PQUhU526dUn-d-E/w400-h100/sc+utf8.png", "Hello", 157, 627)



or simply populate the Image URL and alternate text for the parameter
IMAGE("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf8aRfxLWfr0CQLooZltAZkJjucrOLoA13nE_-TGqy3Pwlf8yaXOV_zMubAY2XJv1qTmkX0-tnqAvr0za3Op2g3XQ4SF-ZNtW4NoRyFCB6rGzlXmbJaFM9QRS2RAt2PQUhU526dUn-d-E/w400-h100/sc+utf8.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.




2 comments:

  1. Hello,

    I used the formula field to display the product Images but its only good got 5000 Compile size. Wnated to know if there is an option for to display 100+ products

    ReplyDelete
    Replies
    1. I don't think using formula is a good idea to display many combination of images, have you look at idea exchange https://appexchange.salesforce.com/appxSearchKeywordResults?keywords=image

      Delete

Page-level ad