fixed glitch causing worng thumbs when limiting images in meta

This commit is contained in:
Sadaqat Ali 2022-10-02 19:13:21 +05:00
parent b255225d61
commit fe223e08af

View File

@ -221,8 +221,7 @@ export const extractMetadata = (body: string, thumbUrl?: string) => {
const mUrls = extractUrls(body);
const mUsers = body && body.match(userReg);
const extractedImages = extractImageUrls({urls:mUrls});
const matchedImages = extractedImages.length ? extractedImages.filter((element,index) => index < 10) : []; //filter only first 10 images
const matchedImages = extractImageUrls({urls:mUrls});
const matchedLinks = [];
const matchedUsers = [];
@ -243,7 +242,7 @@ export const extractMetadata = (body: string, thumbUrl?: string) => {
matchedImages.sort((item) => (item === thumbUrl ? -1 : 1));
}
out.image = matchedImages;
out.image = matchedImages.slice(0, 10); // return only first 10 images
}
if (mUsers) {