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
v1.18.x
gasoved 4 years ago committed by GitHub
parent 3ba0575584
commit d28581eb6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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) {

Loading…
Cancel
Save