From faae66b9662e83bf3c53bf21678c3f5ffc70a553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=84=E6=B2=A8?= Date: Mon, 9 Sep 2024 21:39:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=BE=E7=89=87alt?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=97=B6Fancybox=20caption=E8=BE=93=E5=87=BA?= =?UTF-8?q?undefined=E7=9A=84=E9=97=AE=E9=A2=98=20(#925)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/tags/fancybox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tags/fancybox.js b/scripts/tags/fancybox.js index 292dcfe37..40c1b95f3 100644 --- a/scripts/tags/fancybox.js +++ b/scripts/tags/fancybox.js @@ -22,7 +22,7 @@ function buidImgFancybox(content, group) { let imgList = html.match(//g) || []; imgList.forEach(item => { const url = (item.match(/\ssrc=['"](.*?)['"]/) || [])[1]; - const alt = (item.match(/\salt=['"](.*?)['"]/) || [])[1]; + const alt = (item.match(/\salt=['"](.*?)['"]/) || [])[1] || ''; const newItem = item.replace('img', 'img fancybox itemprop="contentUrl"'); // 避免出现重复替换,打个标 const result = `
${buidAlt(imageTags || alt)}
`; html = html.replace(item, result.trim());