How to add image from "db_image" table on service portal

sayan3
Tera Contributor

Hello All,
We have a requirement to showing the image on service portal.
Instead of showing Image we are getting image sys_id.
We want to fetch the image from db_image table. 

Any help on this would be appreciated.

Thanks,
Sayan 

4 REPLIES 4

Josh Virelli
Tera Guru

Hi Sayan,

To show the image, you need the value from the "Name" field on the db_image record. We can grab that value by getting the GlideRecord of that db_image record using the Sys ID. Here's a function to do this. Just pass in the sys_id of the db_image record and it will output the URL path you will use in the src attribute in the img tag.

function getImageLink(imgSysId){
	var img = new GlideRecord('db_image');
	img.get(imgSysId);
	return '/'+img.getValue('name');
}

If my answer was Helpful or solved your issue, please mark it as "Helpful" or "Correct"

Thanks!

Josh

Hey Sayan,

Was my answer able to resolve your question? What issues are you still having?

Thanks,

Josh

 

Hi Josh,
thanks for your suggestion.
i am using oob widget image carousel , which is fixed my issue.

Thanks,
sayan

Miguel Donayre
ServiceNow Employee
ServiceNow Employee

If you are using the "db_image" table, you can use this script. You can even add the image to the knowledge article and look at the source code and copy that code too. 

<p><img style="align: baseline;" title="" src="<filename.file type>"***Change the name** alt="" width="315" height="160" align="baseline" border="" hspace="" vspace="" /></p>

<p><img style="align: baseline;" title="" src="images.jpegx" alt="" width="315" height="160" align="baseline" border="" hspace="" vspace="" /></p>

 

find_real_file.png

find_real_file.png

find_real_file.png