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
  • 362 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

March 19, 2019

Sure, I was thinking of using classes, but in reverse whereby only those with the class assigned will not have the zoomable function. Well anyway, looks like there's no way around it. Thanks for all your help Joshua!

August 15, 2019

Nice one Joshua. Works great!

How can I add a hover note or something to say press esc to close?

Trapta11
August 22, 2019

Hi @Jacques van Rensburg,

You may use title in order to something like this. Here are few links for reference, you may want to look at these:

Thanks

August 23, 2019

Thanks. Had a quick look and see some options that should work :)

February 6, 2020

Hi, I'm unable to get this to work. I followed the directions, but no luck. Any ideas? Thank you.

 

Joshua25
Joshua25Author
February 6, 2020

Eric,

Do you have the class name on the image you want to expand?

<img class="fancybox" src="image.png" alt="alt text">

February 6, 2020

Hi Joshua,

Thanks for the prompt response. No, I don't have the class name on the image. That must be it. How do I put a class name on an image? Do I change the file name? Or do these images need to be added via CSS; not the image uploader in articles? Thanks again.

February 6, 2020

UPDATE: I used the source code button in the WYSIWYG editor to add the class name to each image, however, it didn't do anything. Thoughts?

Joshua25
Joshua25Author
February 6, 2020

Eric,

After you load the image with the uploader in the article, click on the Source Code button on the right side of the editor.

In the Code pop-up, add the class name to the image tag, as you see above. You don't need to do anything else. 

Good luck!

Joshua

February 6, 2020

Hi Josh,

I did this, but it didn't do anything. Any other ideas?