You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
hexo-theme-yorha/scripts/lazyload.js

14 lines
532 B

/*
edited from post_lazyload.js in Butterfly theme
*/
function lazyload(htmlContent) {
const config = hexo.theme.config.lazyload
if (!config.enable) return
const bg = hexo.theme.config.lazyload.placeholder ? urlFor(hexo.theme.config.lazyload.placeholder) : 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'
return htmlContent.replace(/(<img.*? src=)/ig, `$1 "${bg}" data-src=`)
}
hexo.extend.filter.register('after_render:html', data => {
return lazyload.call(this, data)
})