How to make image enlarge on double click

Hitoshi Ozawa
Giga Sage
Giga Sage

I'm inserting a image as a thumbnail in an article and want the image to show up in original size when it is double clicked.

I see some images in ServiceNow educational courses that'll expand when I click on it.

Currently, if I just insert an image as a thumbnail, it won't expand on double-click. Would appreciate if someone would show me how to expand the image on double click.

1 ACCEPTED SOLUTION

in source code you will apply something like below 

Screenshot :

 

find_real_file.png

 

 

 

<p>Scrolling text</p>
<p>&nbsp;</p>
<div class="imageContainer"><img src="setValue%20in%20ui%20page.pngx" width="700" height="650" /></div>
<style>
.imageContainer > img:hover {
width: 500px;
height: 200px;
}

</style>
<p>&nbsp;</p>
<p>&nbsp;</p>

 

Note: "setValue%20in%20ui%20page.pngx" : this would your image 

 

make the changes in style based on your need. 

 

if my answer helped you , kindly mark it as correct and helpful.

 

 

View solution in original post

8 REPLIES 8

Lorenzo Stermie
Kilo Guru

Hello,

If you use any CSS or Java script you will also have to update our HTML sanitizer to allow whatever coding to be used.

Out of the box I believe the <detail> is the only html feature that will let you do this (and you can use it for either images or text.

 Start by looking at the HTML Code of your article: find_real_file.png

You will then need to locate your image, this will look something like this:
find_real_file.png

You will then need to REPLACE the image string with a different code, here is an example:

<details>
<summary>Click to expand picture<br><img src="/sys_attachment.do?sys_id=32d17067dbb74c18469089584b96193b" width="72" height="96" /></summary>
<p><img src="/sys_attachment.do?sys_id=32d17067dbb74c18469089584b96193b"  /></p>
</details> 

 

 

 

Click to expand picture
find_real_file.png

 

find_real_file.png

 

 Here is a more detailed breakdown:

find_real_file.png

 

Basically your code will be:

<details>
<summary>
Text or image of your summary
</summary>
Text of image you get to see when you click on the summary
</details>

Hope this helps

Lorenzo

PS: this code doesn't appear to work on the Community forum, so when you click the image above nothing will happen, but do try it on your instance.

Thanks for your suggestion. When I click on the image in the community forum (i.e. here), I do get expanded image. However, before I expland, the enlarged image is also appearing after the thumbnail.

I tried it in Knowledge base article in my Orlando release, I'm getting "details" at the end of the article. If I click on the details link, expanded image do appear but then I can only have one set of image per article instead of being able to expand each image individually. It seems like ServiceNow is parsing the html source and separating the content in summary and in details.

Sorry, using <details> and <summary> in my Orlando instance doesn't work.

Hi Hozawa,

I've noticed that too, the forum must be setup differently compared to the SN KB.

Have you tried something like this to handle multiple images in a single article:

<details>
<summary>
Thumbnail 1
</summary>
Full size image 1
</details>

<details>
<summary>
Thumbnail 2
</summary>
Full size image 2
</details>

For me this works.

Sorry, your solution doesn't work. It seems I can use css in knowledge articles but I've found I'm not able to use event such as :focus.