From d28581eb6ab9d03c7165ab426f9833996f1078b3 Mon Sep 17 00:00:00 2001 From: gasoved Date: Mon, 14 Dec 2020 22:24:48 +0300 Subject: [PATCH] feat: show alt text instead of images in teasers (#9107) * feat: show alt text instead of images in teasers * refactor: from utils to local function --- src/topics/teaser.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/topics/teaser.js b/src/topics/teaser.js index 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(/]*>/gi, '$1'); + } + async function handleBlocks(uid, teasers) { const blockedUids = await user.blocks.list(uid); if (!blockedUids.length) {