"Easy image gallery in a modal"
Bootstrap 3.2.0 Snippet by lalfayyadh

<link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="row"> <div class="col-lg-12"> <div class="col-lg-4"> <img class="thumbnail" src="http://placehold.it/100x100" data-toggle="modal" data-image="http://placehold.it/200x100" data-target="#image-gallery"> </div> <div class="col-lg-4"> <img class="thumbnail" src="http://placehold.it/100x100" data-toggle="modal" data-image="http://placehold.it/300x100" data-target="#image-gallery"> </div> <div class="col-lg-4"> <img class="thumbnail" src="http://placehold.it/100x100" data-toggle="modal" data-image="http://placehold.it/400x100" data-target="#image-gallery"> </div> </div> <button data-toggle="modal" data-target="#image-gallery">LAUNCH</button> <div class="modal fade" id="image-gallery" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-body"> <img id="image-gallery-image" class="slide-img-preview" src=""> </div> </div> </div> </div>
.slide-img-preview { width:380px; height:100px}
$(document).ready(function(){ loadGallery(true, 'img.thumbnail'); /** * * @param setIDs Sets IDs when DOM is loaded. If using a PHP counter, set to false. * @param setClickAttr Sets the attribute for the click handler. */ function loadGallery(setIDs, setClickAttr){ var current_image, selector, counter = 0; function updateGallery(selector) { var $sel = selector; $('#image-gallery-image').attr('src', $sel.data('image')); } $(setClickAttr).on('click',function(){ updateGallery($(this)); }); } });

Related: See More


Questions / Comments: