Skip to content

Commit

Permalink
fix(#9): Fix fancybox invalid when enable the lazyload of image
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Aug 28, 2019
1 parent 0ca64cd commit 13122eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,16 @@ Stun.utils = Stun.$u = {
var $img = $(this);
var imgTitle = $img.attr('title') || $img.attr('alt');
var $imgWrap = $img.parent('a');
var imgSource = ['data-src', 'data-original', 'src'];
var imgSrc = '';

if (!$imgWrap[0]) {
var imgSrc = $img.attr('data-original') || $img.attr('src');
for (var i = 0; i < imgSource.length; i++) {
if ($img.attr(imgSource[i])) {
imgSrc = $img.attr(imgSource[i]);
break;
}
}

$imgWrap = $img.wrap('<a class="fancybox" href="' + imgSrc +
'" itemscope itemtype="http://schema.org/ImageObject" itemprop="url"></a>'
Expand Down

0 comments on commit 13122eb

Please sign in to comment.