Page 1 of 1

Lightbox image

Posted: Tue Apr 09, 2024 7:19 pm
by mbory
Hi, has anyone added a lightbox system for images yet? And could help me to configure one please?

Thank you :)

Re: Lightbox image

Posted: Wed Apr 10, 2024 11:19 am
by mbory
I've tried using Lightbox2.js, but the problem is that TinyMCE automatically deletes all attributes added to it, even if I add in raw in the editor <a href="imgLink" data-lightbox="image">, it will delete the data-lightbox

https://lokeshdhakar.com/projects/lightbox2/

Re: Lightbox image

Posted: Thu Apr 11, 2024 3:57 pm
by Klemen
I never added this, but it's most likely removed by the HTMLPurifier library.

You will need to edit /inc/htmlpurifier/HeskHTMLPurifier.php

Just ABOVE this code

Code: Select all

$purifier = new HTMLPurifier($config);
Add something like

Code: Select all

$def = $config->getHTMLDefinition(true);
$def->addAttribute('a', 'data-lightbox', 'Text');
Save and test.

Re: Lightbox image

Posted: Thu Apr 11, 2024 5:49 pm
by mbory
Oh thank you ! it no longer removes the attribute, I'm going to test the lightbox library :)

Re: Lightbox image

Posted: Thu Apr 11, 2024 6:01 pm
by mbory
Hmm, so I use https://lokeshdhakar.com/projects/lightbox2/
I use CDN link here : https://cdnjs.com/libraries/lightbox2

But it dosen't work, my image open in a new tab

Re: Lightbox image

Posted: Thu Apr 11, 2024 6:17 pm
by Klemen
Can you link to a test KB article?