Deduplicated code for image expansion into the page overlay

It now also supports WEBP links, and is compatible with Google Cloud
Storage (which adds ?blablabla to links).
This commit is contained in:
2017-09-29 16:46:27 +02:00
parent 2603c4f44f
commit f42334453c
6 changed files with 21 additions and 58 deletions

View File

@@ -0,0 +1,18 @@
$(function() {
/* Expand images when their link points to a jpg/png/gif/webp */
var imgs = $('.expand-image-links a img')
.off('click')
.on('click', function(e){
var $img = $(this);
var href = $img.parent().attr('href');
if (href.match("\\.(jpg|png|gif|webp)\\W?")) {
var src = $img.attr('src');
var overlay_img = $('<img>').attr('src', src);
$('#page-overlay')
.addClass('active')
.html(overlay_img);
e.preventDefault();
}
});
});