Fluid Responsive Photo Gallery with jQuery and Bootstrap

Fluid Responsive Photo Gallery with jQuery and Bootstrap
File Size: 19.6 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

A super lightweight JavaScript plugin that creates a responsive, flexible thumbnail gallery using Bootstrap grid system and displays large version of the image in a lightbox slider using Bootstrap modal component.

How to use it:

1. Include the Bootstrap Photo Gallery's script in your Bootstrap project which has jQuery library included.

<link href="/path/to/bootstrap.min.css" rel="stylesheet">
<script src="/path/to/jquery.min.js"></script>
<script src="/path/to/bootstrap.min.js"></script>
<script src="/path/to/photo-gallery.js"></script>

2. Add images to the photo gallery using Bootstrap grid system.

<ul class="row">

  <li class="col-lg-2 col-md-2 col-sm-3 col-xs-4 col-xxs-12">
      <img class="img-responsive" src="1.jpg">
      <div class="text">Caption 1</div>
  </li>
  <li class="col-lg-2 col-md-2 col-sm-3 col-xs-4 col-xxs-12">
      <img class="img-responsive" src="2.jpg">
      <div class="text">Caption 2</div>
  </li>

  <li class="clearfix visible-sm-block"></li>

  <li class="col-lg-2 col-md-2 col-sm-3 col-xs-4 col-xxs-12">
      <img class="img-responsive" src="3.jpg">
      <div class="text">Caption 3</div>
  </li>

  <li class="col-lg-2 col-md-2 col-sm-3 col-xs-4 col-xxs-12">
      <img class="img-responsive" src="4.jpg">
      <div class="text">Caption 4</div>
  </li>

  ...

</ul>

3. Create a Bootstrap modal to showcase all the large images in a popup slider.

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-body">
      </div>
    </div>
  </div>
</div>

4. Default plugin settings.

$('ul.row').bsPhotoGallery({
  'classes' : 'col-lg-2 col-md-2 col-sm-3 col-xs-4',
  'showControl' : true,
  'hasModal' : true, 
  'fullHeight' : true,
  'iconClose' : 'glyphicon glyphicon-remove-circle',
  'iconLeft' : 'glyphicon glyphicon-chevron-left',
  'iconRight' : 'glyphicon glyphicon-chevron-right'
});

Change log:

2017-07-14

  • added show Control setting

2017-01-04

  • Fixed bug that overwrote images in other modals

2016-07-08

  • Added more options.

2016-06-25

  • Added external CSS, large modal, icons for prev next, modal titles and text

2015-12-14

  • added support for showing a different / larger image in modal

2015-11-15


This awesome jQuery plugin is developed by michaelsoriano. For more Advanced Usages, please check the demo page or visit the official website.