Image viewer
The image viewer pattern provides a full screen viewing experience for a single image or for a gallery of images. When the thumbnail image is clicked, the image will appear in a full screen modal. In the modal, the user may pan the image, zoom in, and zoom out. Optional descriptive text about the image can be toggled on or off.
The widths for the thumbnails in the examples below are sized with the Boostrap grid classes. The grid classes may be modified to suit your scenario.
Single image mode
In the single image mode, the modal will not contain next and previous buttons.
Demo
Code
<script src="js/jquery-2.2.4.min.js"></script>
<script src="js/zingtouch.min.js"></script>
<script src="js/coc.imageviewer.js"></script>
<!-- To size the thumbnail, you may wrap it in a Bootstrap grid column or
choose your own method to size it. -->
<div class="row">
<!-- Change the Bootstrap column classes as necessary. -->
<div class="col-6 col-sm-4 col-md-3 col-lg-2">
<!-- Image thumbnail -->
<div class="imgviewer-thumb">
<button>
<!-- Populate the data-image attribute with the link to the
full-size image to be displayed in the image viewer modal. -->
<span class="background-image {{ ratio-1x1 | ratio-16x9 | ratio-4x3 | ratio-3x4 }}"
style="background-image: url( '{{ Thumbnail URL (e.g. image.jpg) }}' );"
data-image="{{ Full image URL (e.g. image.jpg) }}"></span>
<span class="caption">{{ Thumbnail caption }}</span>
</button>
<!-- Optional additional detail about the image. The details are
hidden in the thumbnail view and are displayed in the image viewer modal. -->
<div class="caption-details">
{{ Additional image details (may contain HTML) }}
</div>
</div>
</div>
</div>
Gallery mode
In the gallery mode, the modal will contain next and previous buttons to cycle through the images. There is also an indicator displaying which image is currently in view.
Demo
Multiple galleries
Multiple galleries will work on the same page. The next and previous buttons in the gallery modal will only cycle through the images belonging to the current gallery.
Code
<script src="js/jquery-2.2.4.min.js"></script>
<script src="js/zingtouch.min.js"></script>
<script src="js/coc.imageviewer.js"></script>
<!-- The `imgviewer-gallery` class must be applied to a wrapper element
surrounding all thumbnails in the gallery.
To size the thumbnail, you may wrap it in a Bootstrap grid column or
choose your own method to size it. -->
<div class="imgviewer-gallery row">
<!-- Change the Bootstrap column classes as necessary. -->
<div class="col-6 col-sm-4 col-md-3 col-lg-2">
<!-- Image thumbnail -->
<div class="imgviewer-thumb">
<button>
<!-- Populate the data-image attribute with the link to the
full-size image to be displayed in the iamge viewer modal. -->
<span class="background-image {{ ratio-1x1 | ratio-16x9 | ratio-4x3 | ratio-3x4 }}"
style="background-image: url( '{{ Thumbnail URL (e.g. image.jpg) }}' );"
data-image="{{ Full image URL (e.g. image.jpg) }}"></span>
<span class="caption">{{ Thumbnail caption }}</span>
</button>
<!-- Optional additional detail about the image. The details are
hidden in the thumbnail view and are displayed in the image viewer modal. -->
<div class="caption-details">
{{ Additional image details (may contain HTML) }}
</div>
</div>
</div>
<!-- Add additional thumbnails as needed. -->
...
</div>