From 374f9556d14928903111d11c4f92eb33ece2f9c0 Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Thu, 5 Feb 2015 17:25:35 +0100 Subject: [PATCH] Don't try to preview images when there are none --- js/imgpreview.full.jquery.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/js/imgpreview.full.jquery.js b/js/imgpreview.full.jquery.js index c2f370342..eb5fdec1c 100644 --- a/js/imgpreview.full.jquery.js +++ b/js/imgpreview.full.jquery.js @@ -55,17 +55,21 @@ // Re-usable means to add prefix (from setting): function addPrefix(src) { - return src.replace(/(\/?)([^\/]+)$/,'$1' + s.thumbPrefix + '$2'); + return src && src.replace(/(\/?)([^\/]+)$/,'$1' + s.thumbPrefix + '$2'); } if (s.preloadImages) { (function(i){ var tempIMG = new Image(), callee = arguments.callee; - tempIMG.src = addPrefix($($collection[i]).attr(s.srcAttr)); - tempIMG.onload = function(){ - $collection[i + 1] && callee(i + 1); - }; + var src = $($collection[i]).attr(s.srcAttr) + if (src) + { + tempIMG.src = addPrefix(src); + tempIMG.onload = function(){ + $collection[i + 1] && callee(i + 1); + }; + } })(0); }