Expanding images in Help Center articles | The place for Zendesk users to come together and share
Skip to main content
Joshua25
September 23, 2018

Expanding images in Help Center articles

  • September 23, 2018
  • 67 replies
  • 354 views

Unfortunately the ZenDesk Help Center does not natively allow you to have images that expand in size and show in a lightbox pop-up. However, this functionality is not difficult to provide with a small amount of work.

Fancybox is a JavaScript tool that allows you to show images in a lightbox pop-up. The process of using this tool is easier than ever, because starting with version 3, you can just link to the hosted file. This makes using it in ZenDesk as simple as four steps:

1. Go to the code editor for your theme. To do this, go to Settings, hover over your theme and click View Theme, click on the "..." next to Live, click Edit Code, then select the file you need to edit in the left column.

2. Add the links to the fancybox code in your document_head.hbs (the bottom of that file is fine):

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js"></script>

3. Add the following to your script.js file, right above the closing "});". You can change the ".fancybox" in the first line to use a different class name if you like, or remove the ".fancybox" altogether to make all of your images show in the pop-up when clicked.

$('.article-body img.fancybox').on('click', function() {
$.fancybox.open([
{
src : $(this).attr("src"),
opts : {},
},
]);
});

The placement of this code is important. Be sure to include it before the closing bracket and parenthesis so that it can be loaded properly.

4. In the article, add the image using the image loader or by pasting it in.

5. Click on the Source Code button in the menu bar to open the HTML view pop-up.

6. Add class="fancybox" (or the class name you chose) in the HTML code on any image you like. 

7. Close the HTML view pop-up and save the page.

Important: Be sure the images you want show in the FancyBox are all large enough to make the pop-up useful. I find this makes the most sense for application screenshots. 

-----------------------

Update 4/3/20: As mentioned by Robert Holm below, if you are having trouble with the method for using fancybox described here, you might want to check out the detailed instructions here.

 

67 replies

Heather13
Contributor
September 24, 2018

Be-a-u-tiful! Thank you for this awesome image tip!

October 29, 2018

I love this solution, exactly what we needed!

Employee
October 29, 2018

Hi Eva! I'm so glad it worked for you!

November 12, 2018

Hello, can someone tell me what I'm doing wrong? I can not figure it out myself.

I need it for all the pictures on the hc


Joshua25
Joshua25Author
November 12, 2018

Marco, be sure to place the script addition to the bottom of the file BEFORE the closing "});"

November 12, 2018

So you mean like this: [this it not working :]

Joshua25
Joshua25Author
November 12, 2018

I am not sure that the Help Classes Hidden function you have there at the end is written properly. Try moving the Images function above that and seeing if that helps. If so, then the Help Classes function needs to be fixed. 


Otherwise there is something else going on in that code. You might try using a JavaScript validator to check it for issues: http://esprima.org/demo/validate.html

November 13, 2018

I got it working :). This is actually easier.


Thanks for the help

 

Employee
November 15, 2018

I'm glad you got it working, Marco! Thanks for helping out, Joshua. :)

December 17, 2018

If you want to include this in your community posts, you should add this to "scripts.js":

//fancybox image zooming in community
$('.post-body img.fancybox').on('click', function() {
$.fancybox.open([
{
src : $(this).attr("src"),
opts : {},
},
]);
});

You can also exclude ".fancybox" to make all of your images show in the pop-up when clicked in your community posts.