mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
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
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user