Node.js based forum software built for the modern web
feat: show alt text instead of images in teasers (#9107)
gasovedd28581eb6ab9
diff --git a/src/topics/teaser.js b/src/topics/teaser.jsindex 8bf4906907..6b5a000117 100644--- a/src/topics/teaser.js+++ b/src/topics/teaser.js@@ -76,7 +76,7 @@ module.exports = function (Topics) {if (tidToPost[topic.tid]) {tidToPost[topic.tid].index = meta.config.teaserPost === 'first' ? 1 : counts[index];if (tidToPost[topic.tid].content) {- tidToPost[topic.tid].content = utils.stripHTMLTags(tidToPost[topic.tid].content, tags);+ tidToPost[topic.tid].content = utils.stripHTMLTags(replaceImgWithAltText(tidToPost[topic.tid].content), tags);}}return tidToPost[topic.tid];@@ -86,6 +86,10 @@ module.exports = function (Topics) {return result.teasers;};+ function replaceImgWithAltText(str) {+ return String(str).replace(/<img .*?alt="(.*?)"[^>]*>/gi, '$1');+ }+async function handleBlocks(uid, teasers) {const blockedUids = await user.blocks.list(uid);if (!blockedUids.length) {