From f9b18f5471d06033a58e89c82225015e69e6bb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20H=C3=BCsges?= Date: Fri, 26 Feb 2016 13:48:12 +0100 Subject: [PATCH] Lightbox to WordPress gallery --- src/js/lightbox.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/js/lightbox.js b/src/js/lightbox.js index 352bb863..015addd3 100644 --- a/src/js/lightbox.js +++ b/src/js/lightbox.js @@ -63,6 +63,7 @@ Lightbox.prototype.init = function() { this.enable(); this.build(); + this.wordpress(); }; // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes @@ -137,6 +138,20 @@ }); }; + // Lightbox to WordPress gallery + Lightbox.prototype.wordpress = function() { + if ($('meta[name=generator][content*=WordPress]').length === 1) { + $('.gallery').each(function () { + var id = $(this).attr('id'); + $(this).find('a').each(function () { + if ($(this).attr('href').indexOf('attachment_id') === -1) { + $(this).attr('data-lightbox', id); + } + }); + }); + } + }; + // Show overlay and lightbox. If the image is part of a set, add siblings to album array. Lightbox.prototype.start = function($link) { var self = this;