Search code examples
lightbox2

Lightbox 2 - how to add options


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


Solution

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