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());