I'm trying to implement an image gallery using Lightbox. Using the example everything works fine. Since I'm using Bootstrap and already linking to JQuery I'd like use lightbox.js
instead of lightroom-plus-jquery.js
. This, however, breaks the functionality and all images are opened fullscreen like regular links.
On the official website I couldn't find any information and no other example code is provided. So I hope someone here can help me fix it.
This is a minimal html based on the example:
<html>
<head>
<meta charset="utf-8">
<title>Lightbox Example</title>
<link rel="stylesheet" href="css/lightbox.css">
</head>
<body>
<section>
<div>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-3.jpg" data-lightbox="example-set" data-title="Click the right half of the image to move forward."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-3.jpg" alt=""/></a>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-4.jpg" data-lightbox="example-set" data-title="Or press the right arrow on your keyboard."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-4.jpg" alt="" /></a>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-5.jpg" data-lightbox="example-set" data-title="The next image in the set is preloaded as you're viewing."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-5.jpg" alt="" /></a>
<a class="example-image-link" href="http://lokeshdhakar.com/projects/lightbox2/images/image-6.jpg" data-lightbox="example-set" data-title="Click anywhere outside the image or the X to the right to close."><img class="example-image" src="http://lokeshdhakar.com/projects/lightbox2/images/thumb-6.jpg" alt="" /></a>
</div>
</section>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="js/lightbox.js"></script>
</body>
</html>
Problem with jquery-3.3.1.slim.min.js
Please Use jquery.min.js
.
Example is Here : https://codepen.io/mrdvpatel/pen/BgVpZQ
@import url('https://fonts.googleapis.com/css?family=Montserrat&display=swap');
*{
font-family: 'Montserrat', sans-serif;
}
.example-image-link img {
width: 24%;
height: 200px;
object-fit: cover;
}
<html>
<head>
<meta charset="utf-8">
<title>Lightbox Example</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.0/css/lightbox.css">
</head>
<body>
<section class="images">
<a class="example-image-link" href="https://dummyimage.com/600x400/000/fff" data-lightbox="example-set" data-title="Click the right half of the image to move forward."><img class="example-image" src="https://dummyimage.com/600x400/000/fff" alt=""/></a>
<a class="example-image-link" href="https://dummyimage.com/600x400/ff0000/fff" data-lightbox="example-set" data-title="Or press the right arrow on your keyboard."><img class="example-image" src="https://dummyimage.com/600x400/ff0000/fff" alt="" /></a>
<a class="example-image-link" href="https://dummyimage.com/400x600/000/fff" data-lightbox="example-set" data-title="The next image in the set is preloaded as you're viewing."><img class="example-image" src="https://dummyimage.com/400x600/000/fff" alt="" /></a>
<a class="example-image-link" href="https://dummyimage.com/400x600/ff0000/fff" data-lightbox="example-set" data-title="Click anywhere outside the image or the X to the right to close."><img class="example-image" src="https://dummyimage.com/400x600/ff0000/fff" alt="" /></a>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.0/js/lightbox.js"></script>
</body>
</html>