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:
18
src/scripts/tutti/8_expand_image.js
Normal file
18
src/scripts/tutti/8_expand_image.js
Normal 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();
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user