Support video thumbnails
This commit is contained in:
parent
4e755ace36
commit
035069f505
4 changed files with 124 additions and 18 deletions
|
|
@ -25,8 +25,8 @@ export const ROOM_TYPE_CHANNEL = "im.keanu.room_type_channel";
|
|||
|
||||
export const STATE_EVENT_ROOM_TYPE = "im.keanu.room_type";
|
||||
|
||||
const THUMBNAIL_MAX_WIDTH = 160;
|
||||
const THUMBNAIL_MAX_HEIGHT = 160;
|
||||
export const THUMBNAIL_MAX_WIDTH = 160;
|
||||
export const THUMBNAIL_MAX_HEIGHT = 160;
|
||||
|
||||
// Install extended localized format
|
||||
dayjs.extend(localizedFormat);
|
||||
|
|
@ -391,7 +391,7 @@ class Util {
|
|||
return [encryptedBytes, encryptedFile];
|
||||
}
|
||||
|
||||
sendFile(matrixClient, roomId, file, onUploadProgress, threadRoot, dimensions) {
|
||||
sendFile(matrixClient, roomId, file, onUploadProgress, threadRoot, dimensions, thumbnail) {
|
||||
const uploadPromise = new UploadPromise(undefined);
|
||||
uploadPromise.wrappedPromise = new Promise((resolve, reject) => {
|
||||
var reader = new FileReader();
|
||||
|
|
@ -419,11 +419,22 @@ class Util {
|
|||
|
||||
var description = file.name;
|
||||
var msgtype = "m.file";
|
||||
|
||||
if (thumbnail) {
|
||||
thumbnailData = thumbnail.data;
|
||||
thumbnailInfo = {
|
||||
mimetype: thumbnail.mimetype,
|
||||
size: thumbnail.size,
|
||||
w: thumbnail.w,
|
||||
h: thumbnail.h,
|
||||
};
|
||||
}
|
||||
|
||||
if (file.type.startsWith("image/")) {
|
||||
msgtype = "m.image";
|
||||
|
||||
// Generate thumbnail?
|
||||
if (dimensions) {
|
||||
if (dimensions && !thumbnail) {
|
||||
const w = dimensions.width;
|
||||
const h = dimensions.height;
|
||||
if (w > THUMBNAIL_MAX_WIDTH || h > THUMBNAIL_MAX_HEIGHT) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue