Files
cinny/src/app/utils/mediaThumb.ts
T

11 lines
518 B
TypeScript
Raw Normal View History

import { MatrixEvent } from 'matrix-js-sdk';
import { IImageInfo, IThumbnailContent } from '../../types/matrix/common';
/** The mxc to show as a thumbnail for an image/video event (thumbnail if present, else the file). */
export function getThumbMxc(mEvent: MatrixEvent): string | undefined {
const c = mEvent.getContent();
const isEnc = !!c.file;
const info: (IImageInfo & IThumbnailContent) | undefined = c.info;
return isEnc ? (info?.thumbnail_file?.url ?? c.file?.url) : (info?.thumbnail_url ?? c.url);
}