fix lazyload on old images
This commit is contained in:
@@ -1065,7 +1065,24 @@
|
|||||||
|
|
||||||
//wrap images on old posts
|
//wrap images on old posts
|
||||||
$('.single-content>.wp-block-image>img, .single-content>.wp-block-gallery>img').each(function () {
|
$('.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).wrap('<a class="cb-gallery" href="' + src + '" ></a>')
|
||||||
// $(this).parent('p').addClass('wp-block-image')
|
// $(this).parent('p').addClass('wp-block-image')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user