Lightbox 2 - how to add options

jk105 picture jk105 · Jul 4, 2015 · Viewed 7.1k times · Source

When I try to use the Lightbox2 options code I get an error saying 'lightbox is not defined'. It works fine when I don't add the option code. What is the correct way to implement the options, the website only has this...

lightbox.option({ 'resizeDuration': 200, 'wrapAround': true })

http://lokeshdhakar.com/projects/lightbox2/#options

Answer

herzrasen picture herzrasen · Jul 7, 2015

You can set the lightbox options in the file where you include the lightbox.js file. Also please ensure to include jquery before lightbox.

The code below is inside a block in a php file:

    <body>
        ...
        <script src="js/jquery-1.11.3.min.js"></script> // <-- this is important
        <script src="js/lightbox.js"></script>
        <script>
            lightbox.option({
                'resizeDuration' : 200,
                'wrapAround' : true
            });
        </script>
        ...
    </body>