While working as a Salesforce admin, recently, I got a client requirement to automatically display the company logo on the account record as soon as a new account is created or an updated account name.
The client did not want users to upload logos manually. Instead, they wanted Salesforce to show the correct logo based on the Account Name.
To meet this requirement, I created a Formula field using the IMAGE() function. This formula checks the account name and displays the matching logo from a static resource where we used to store images.
In this tutorial, we will learn how to use the IMAGE() Function in Salesforce. We will also learn the syntax and real-world business examples of when we can use the function.
What is the Salesforce IMAGE() Function?
The Salesforce IMAGE() function is one of the functions used to display an image in object fields. This Salesforce IMAGE() Function is used to insert an image with alternate text and height and width specifications.
In addition, the following is the syntax of the Salesforce IMAGE function:
IMAGE(image_url, alternate_text, height, width)
Here is a detailed description of the parameters:
- image_url: The image_url parameter specifies the path of the image that you want to insert.
- alternate_text: The alternate_text parameter specifies the text to display when the image can’t be displayed or rendered due to technical or network issues. The screen reader software uses this alternate text.
- height: The height parameter specifies the vertical size of the inserted image. It always takes the size of an inserted image in pixels.
- width: The width parameter specifies the width, or you can say the horizontal size of the image that you want to set for the inserted image. The image width can always be specified in pixels.
In addition, there are some considerations that we must remember while using the IMAGE function:
- Optional Parameters: In Salesforce, the image function accepts four parameters: image_url, alternate_text, height, and width. Of these four parameters, height and width are optional; you can leave them blank if you want.
- Limitation: You cannot display the image for contacts in Salesforce custom fields when the image is referenced via a person’s account.
- Text Type Parameters: Always remember that in Salesforce, the IMAGE function’s image_url and alternate_text parameters are of type text. Make sure to enclose both parameter values in the quotes.
- Availability: You can only use this IMAGE function in formula fields and email templates.
- Number Type Parameter: The height and width parameter of the IMAGE function takes values only as numbers without any quotation marks.
- GETSESSIONID Function: In the IMAGE function, you cannot use the Salesforce GETSESSIONID function as an argument.
- Store Images: You can store the image in the Salesforce Documents and use the URL of the document in the image_url parameter of the IMAGE function as the reference to the image.
- Internet Explorer Settings: If you are using Internet Explorer to display images via the HTTP protocol, you need to adjust the security settings in Explorer; otherwise, you will see a warning prompt.
Additionally, keep in mind that the IMAGE Function returns the result in the form of text, so select the formula return type as TEXT. If you choose any other field type as the return type of the formula field, you will get an error.
Now, we will learn how to add an image to the formula field using the IMAGE() function in Salesforce.
Use the Image() Function in Salesforce
The following steps show how to use the Salesforce IMAGE Function to add an image to a formula field in Salesforce.
- Open Salesforce Lightning mode. Next, click the “Gear Icon” in the top right corner of the page. Click “Setup“ from the dropdown menu to continue.

- The setup page opens when you select the Setup option. Here, the “Object Manager” is found in the Navigation Bar next to the Home tab. Click on it.