Use a modal event listener and pass the image to a modal
Script
$(document).ready(function () { $('#myModal').on('show.bs.modal', function (e) { var img = $(e.relatedTarget).attr('src');
add id="showimg" to the image tag <img> in the modular body
<div class="modal-body"> <img class="img-responsive" src="" alt="" id="showimg"> </div>
Script tag <img>
Yes, you can also do this with the <a> tag
<a> tag
<a class="btn btn-primary btn-xs" href="imagepath" data-target="#myModal" data-toggle="modal">Open Image</a>
and the script event listener will
$(document).ready(function () { $('#myModal').on('show.bs.modal', function (e) { var img = $(e.relatedTarget).attr('href');
Script tag <a>
source share