/*--------------------------------------------------------- NPF images fix v3.0 by @glenthemes [2021] 💌 git.io/JRBt7 Credits: > wrap divs that are next to each other by Nick Craver stackoverflow.com/a/3329249/8144506 > get 'deepest' element script by Balint Bako stackoverflow.com/a/18652986/8144506 ---------------------------------------------------------*/ $(document).ready(function(){ // check jquery version var jqver = jQuery.fn.jquery; var ver = jqver.replaceAll(".",""); $(".npf_row .tmblr-full:not(:only-child)").each(function(){ $(this).wrap("
(Source: " + gp_name + ")
") } } } } }) /*-------------------------------------------------*/ // initiate lightbox on images that didn't originally // come with photo anchor $(".tmblr-full img").click(function(){ if(!$(this).hasClass("post_media_photo")){ var imgsrc = $(this).attr("src"); Tumblr.Lightbox.init([{ low_res:imgsrc, high_res:imgsrc }]); } }); // assign unique ID to each NPF photoset $(".npf_inst").each(function(){ $(this).attr("npf-id","npf_" + Math.random().toString(36).substr(2, 5)) }); // initialize number of images in each NPF photoset, // and create an numerically labelled list function npflineup(){ $(".npf_inst").each(function(){ $(this).find(".tmblr-full").each(function(i){ i = i + 1; $(this).attr("list-order",i); }); $(this).find(".tmblr-full img").each(function(w){ w = w + 1; $(this).parents(".npf_inst").attr("image" + w,$(this).attr("src")) }); }) } npflineup(); // initialize lightbox + clickthrough $(".tmblr-full img").click(function(){ var npfID = $(this).parents("[npf-id]").attr("npf-id"); var npford = $(this).parents(".tmblr-full").attr("list-order"); var npfmax = $(this).parents(".npf_inst") .find(".tmblr-full").length; $(document).on("click", ".lightbox-image", function(){ $(this).attr("npf-id",npfID).attr("order",npford); $(".npf_inst").each(function(){ if($(this).attr("npf-id") == $(".lightbox-image").attr("npf-id")){ npford = Number(npford)+1; if($(this).is("[image" + npford + "]")){ var getnext = $(this).attr("image" + npford); $(".lightbox-image").attr("src",getnext); $(".lightbox-image").addClass("lb-img"); $(".lightbox-image-container").addClass("lb-cont"); } else { if($(".lightbox-image").attr("order") > npfmax){ $(".lightbox-image").removeAttr("order"); } } } }) }) }) // do that thing again if npfs are inside npfs fsfr $(".npf_inst .npf_inst").each(function(){ $(this).children().unwrap(); }) $(".npf_inst + .npf_inst").each(function(){ $(this).appendTo($(this).prev()); $(this).children().unwrap(); }); $(".npf_inst [list-order]").each(function(){ $(this).removeAttr("list-order"); }) npflineup(); /*-------------------------------------------------*/ $("[data-big-photo]").each(function(){ var gwgw = $(this).attr("data-big-photo"); var guppy = new Image(); guppy.src = gwgw; }) });// end ready