fix lazyload on old images

This commit is contained in:
infeeeee
2019-09-13 16:11:23 +02:00
parent f0e2e44980
commit ec3e5525a5

View File

@@ -1065,7 +1065,24 @@
//wrap images on old posts
$('.single-content>.wp-block-image>img, .single-content>.wp-block-gallery>img').each(function () {
let src = $(this).attr('src')
var src = $(this).attr('src')
var datasrc = $(this).attr('data-src')
var srcArr = src.split('.')
switch (srcArr[srcArr.length - 1]) {
case 'jpg':
case 'png':
case 'jpeg':
case 'gif':
break;
default:
if (datasrc) {
src = datasrc
}
break;
}
$(this).wrap('<a class="cb-gallery" href="' + src + '" ></a>')
// $(this).parent('p').addClass('wp-block-image')
})