Introduce a list of image mime types we can support as images
E.g. TIFF will now be handled as a generic file, not image, even though it has mime prefix "image/"
This commit is contained in:
parent
bdc66fa603
commit
4662bcdc7d
10 changed files with 30 additions and 10 deletions
|
|
@ -30,6 +30,17 @@ export const CLIENT_EVENT_MEDIA_INTERVENTION_FLAGS = "im.keanu.proof_hint";
|
|||
export const THUMBNAIL_MAX_WIDTH = 640;
|
||||
export const THUMBNAIL_MAX_HEIGHT = 640;
|
||||
|
||||
export const supportedImageTypes = [
|
||||
"image/bmp",
|
||||
"image/gif",
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg",
|
||||
"image/webp",
|
||||
"image/x-icon"
|
||||
];
|
||||
|
||||
// Install extended localized format
|
||||
dayjs.extend(localizedFormat);
|
||||
dayjs.extend(duration);
|
||||
|
|
@ -437,7 +448,7 @@ class Util {
|
|||
};
|
||||
}
|
||||
|
||||
if (file.type.startsWith("image/")) {
|
||||
if (this.isSupportedImageType(file.type)) {
|
||||
msgtype = "m.image";
|
||||
|
||||
// Generate thumbnail?
|
||||
|
|
@ -940,7 +951,7 @@ class Util {
|
|||
var reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
const file = event.target.files[0];
|
||||
if (file.type.startsWith("image/")) {
|
||||
if (this.isSupportedImageType(file.type)) {
|
||||
try {
|
||||
var image = e.target.result;
|
||||
|
||||
|
|
@ -1236,6 +1247,10 @@ class Util {
|
|||
return false;
|
||||
}
|
||||
|
||||
isSupportedImageType(mime) {
|
||||
return supportedImageTypes.some(prefix => mime.startsWith(prefix));
|
||||
}
|
||||
|
||||
isMobileOrTabletBrowser() {
|
||||
// Regular expression to match common mobile and tablet browser user agent strings
|
||||
const mobileTabletPattern = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Tablet|Mobile|CriOS/i;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue