Use thumbnails instead of mxc download

This commit is contained in:
Jorik Schellekens
2020-09-23 15:30:46 +01:00
parent dd372dbb50
commit ee8c860507
7 changed files with 107 additions and 29 deletions
+15
View File
@@ -182,6 +182,21 @@ export async function getGroupDetails(
.then(GroupSchema.parse);
}
export function getThumbnailURI(
clientURL: string,
mxcId: string,
height: number,
width: number,
): string {
const mxcParse = mxcId.match(/mxc:\/\/(?<server>.+)\/(?<mediaId>.+)/);
if (!mxcParse || !mxcParse.groups) {
throw new Error(`mxc invalid. mxc: ${mxcId}`);
}
// eslint-disable-next-line max-len
return `https://${clientURL}/_matrix/media/r0/thumbnail/${mxcParse.groups.server}/${mxcParse.groups.mediaId}?height=${height}&width=${width}`;
}
/*
* Gets an mxc resource
*/