From 002374b3046b1b3904806389adeee23100bd251e Mon Sep 17 00:00:00 2001 From: XPoet Date: Wed, 5 Oct 2022 00:21:13 +0800 Subject: [PATCH] fix: fixed lazyload not working when `alt` attribute is empty --- scripts/filters/lazyload-handle.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/filters/lazyload-handle.js b/scripts/filters/lazyload-handle.js index 83bdfb3..985ef98 100644 --- a/scripts/filters/lazyload-handle.js +++ b/scripts/filters/lazyload-handle.js @@ -11,9 +11,12 @@ hexo.extend.filter.register( // Match 'img' tags the src attribute. /]*)src="([^"]*)"([^>\/]*)\/?\s*>/gim, function (match, attrBegin, src, attrEnd) { + let hasAlt = false if (!src) return match + ;[attrBegin, attrEnd].forEach(x => { if (x.includes('alt="')) { hasAlt = true } }) return ``