diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2016-03-26 17:15:18 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2016-03-26 17:15:18 +0100 |
commit | 0352e45513762cbcf7f8441a7073be27a4293bc8 (patch) | |
tree | e69c5f24272d82dbd9ade1cebf743fc7b1395f67 /templates | |
parent | df5f964245d3d32c3c5cc56eb292f9aedc74572c (diff) |
Fixed error handling on image thumbnails.
Replaced jquery-lazyload with jquery.lazy which provides an onError
event handler.
Diffstat (limited to 'templates')
-rw-r--r-- | templates/images.tmpl | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/templates/images.tmpl b/templates/images.tmpl index 7de8bd3..4dee28f 100644 --- a/templates/images.tmpl +++ b/templates/images.tmpl @@ -3,15 +3,14 @@ #extends templates.base #def head <script type="text/javascript" src="${settings.virtual_root}s/jquery-2.1.0.min.js"></script> -<script type="text/javascript" src="${settings.virtual_root}s/jquery.lazyload.min.js"></script> +<script type="text/javascript" src="${settings.virtual_root}s/jquery.lazy.min.js"></script> <script type="text/javascript"> - function thumb_onerror(img) { - var no_thumb = '${settings.virtual_root}s/no-thumbnail.png'; - if(img.src != no_thumb) - img.src = no_thumb; - } \$(function() { - \$('img.lazy').lazyload(); + \$('img.lazy').Lazy({ + onError: function(element) { + element.attr('src', '${settings.virtual_root}s/no-thumbnail.png'); + } + }); }); </script> #end def @@ -20,7 +19,7 @@ #if len($files) <div class="image-list"> #for file in $files - <div class="image"><a href="${settings.virtual_root}f/${file.hash}${file.ext}" title="$file.filename"><img class="lazy" data-original="${settings.virtual_root}t/$file.hash" alt="$file.filename" onerror="thumb_onerror(this)" /><noscript><img src="${settings.virtual_root}t/$file.hash" alt="$file.filename" /></noscript></a></div> + <div class="image"><a href="${settings.virtual_root}f/${file.hash}${file.ext}" title="$file.filename"><img class="lazy" data-src="${settings.virtual_root}t/$file.hash" alt="$file.filename" /><noscript><img src="${settings.virtual_root}t/$file.hash" alt="$file.filename" /></noscript></a></div> #end for </div> #else |