mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #12799 add externally linked images to attachment
This commit is contained in:
@@ -370,6 +370,19 @@ Mocks.note = async (post) => {
|
|||||||
attachment.push({ mediaType, url, width, height });
|
attachment.push({ mediaType, url, width, height });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Inspect post content for external imagery as well
|
||||||
|
let match = posts.imgRegex.regex.exec(post.content);
|
||||||
|
while (match !== null) {
|
||||||
|
if (match[1]) {
|
||||||
|
const { hostname, pathname, href: url } = new URL(match[1]);
|
||||||
|
if (hostname !== nconf.get('url_parsed').hostname) {
|
||||||
|
const mediaType = mime.getType(pathname);
|
||||||
|
attachment.push({ mediaType, url });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match = posts.imgRegex.regex.exec(post.content);
|
||||||
|
}
|
||||||
|
|
||||||
attachment = attachment.map(({ mediaType, url, width, height }) => {
|
attachment = attachment.map(({ mediaType, url, width, height }) => {
|
||||||
let type;
|
let type;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user