Merge branch '705-issue-sharing-a-tif-image' into 'dev'
Fix "Issue sharing a .tif image" See merge request keanuapp/keanuapp-weblite!367
This commit is contained in:
commit
71c5103280
10 changed files with 30 additions and 10 deletions
|
|
@ -68,7 +68,7 @@
|
||||||
<interactive-auth ref="interactiveAuth" />
|
<interactive-auth ref="interactiveAuth" />
|
||||||
|
|
||||||
<input id="user-avatar-picker" ref="useravatar" type="file" name="user-avatar"
|
<input id="user-avatar-picker" ref="useravatar" type="file" name="user-avatar"
|
||||||
@change="handlePickedUserAvatar($event)" accept="image/*" class="d-none" />
|
@change="handlePickedUserAvatar($event)" :accept="supportedImageTypes" class="d-none" />
|
||||||
|
|
||||||
<v-dialog v-model="enterRoomDialog" :width="$vuetify.display.smAndUp ? '50%' : '90%'">
|
<v-dialog v-model="enterRoomDialog" :width="$vuetify.display.smAndUp ? '50%' : '90%'">
|
||||||
<v-card>
|
<v-card>
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input id="room-avatar-picker" ref="avatar" type="file" name="avatar" @change="handlePickedAvatar($event)"
|
<input id="room-avatar-picker" ref="avatar" type="file" name="avatar" @change="handlePickedAvatar($event)"
|
||||||
accept="image/*" class="d-none" />
|
:accept="supportedImageTypes" class="d-none" />
|
||||||
|
|
||||||
<div class="join-lang">
|
<div class="join-lang">
|
||||||
<h3 class="mb-2">{{ $t("profile.select_language") }}</h3>
|
<h3 class="mb-2">{{ $t("profile.select_language") }}</h3>
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
type="file"
|
type="file"
|
||||||
name="avatar"
|
name="avatar"
|
||||||
@change="handlePickedAvatar($event)"
|
@change="handlePickedAvatar($event)"
|
||||||
accept="image/*"
|
:accept="supportedImageTypes"
|
||||||
class="d-none"
|
class="d-none"
|
||||||
/>
|
/>
|
||||||
</v-avatar>
|
</v-avatar>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
type="file"
|
type="file"
|
||||||
name="roomAvatar"
|
name="roomAvatar"
|
||||||
@change="handleRoomPickedAvatar($event)"
|
@change="handleRoomPickedAvatar($event)"
|
||||||
accept="image/*"
|
:accept="supportedImageTypes"
|
||||||
class="d-none"
|
class="d-none"
|
||||||
/>
|
/>
|
||||||
</v-avatar>
|
</v-avatar>
|
||||||
|
|
|
||||||
|
|
@ -384,7 +384,7 @@ export default {
|
||||||
|
|
||||||
const mime = blob.type;
|
const mime = blob.type;
|
||||||
|
|
||||||
if (mime.startsWith("image/")) {
|
if (util.isSupportedImageType(mime)) {
|
||||||
var extension = ".png";
|
var extension = ".png";
|
||||||
switch (mime) {
|
switch (mime) {
|
||||||
case "image/jpeg":
|
case "image/jpeg":
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<v-icon class="create-room-avatar__icon default" v-else>$vuetify.icons.room_avatar_placeholder</v-icon>
|
<v-icon class="create-room-avatar__icon default" v-else>$vuetify.icons.room_avatar_placeholder</v-icon>
|
||||||
<v-icon class="create-room-avatar__camera clickable" v-if="!modelValue || !modelValue.image" @click.stop="showRoomAvatarPicker">$vuetify.icons.ic_camera</v-icon>
|
<v-icon class="create-room-avatar__camera clickable" v-if="!modelValue || !modelValue.image" @click.stop="showRoomAvatarPicker">$vuetify.icons.ic_camera</v-icon>
|
||||||
<input id="room-avatar-picker" ref="roomAvatar" type="file" name="roomAvatar"
|
<input id="room-avatar-picker" ref="roomAvatar" type="file" name="roomAvatar"
|
||||||
@change="handlePickedRoomAvatar($event)" accept="image/*" class="d-none" />
|
@change="handlePickedRoomAvatar($event)" :accept="supportedImageTypes" class="d-none" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export const useThumbnail = (source: KeanuEvent | File | undefined) => {
|
||||||
} else if (source) {
|
} else if (source) {
|
||||||
const file = source as File;
|
const file = source as File;
|
||||||
isVideo.value = file.type.startsWith("video/");
|
isVideo.value = file.type.startsWith("video/");
|
||||||
isImage.value = file.type.startsWith("image/");
|
isImage.value = utils.isSupportedImageType(file.type);
|
||||||
fileName.value = file.name;
|
fileName.value = file.name;
|
||||||
fileSize.value = prettyBytes(file.size);
|
fileSize.value = prettyBytes(file.size);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ import Vue3Sanitize from "vue-3-sanitize";
|
||||||
import vuetify from './plugins/vuetify';
|
import vuetify from './plugins/vuetify';
|
||||||
import { Buffer } from 'buffer/'
|
import { Buffer } from 'buffer/'
|
||||||
import { createApp, h } from 'vue';
|
import { createApp, h } from 'vue';
|
||||||
|
import { supportedImageTypes } from '@/plugins/utils';
|
||||||
|
|
||||||
globalThis.Buffer = Buffer;
|
globalThis.Buffer = Buffer;
|
||||||
|
|
||||||
var defaultOptions = Vue3Sanitize.defaults;
|
var defaultOptions = Vue3Sanitize.defaults;
|
||||||
|
|
@ -25,6 +27,9 @@ defaultOptions.allowedTags = [];
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
render: () => h(App)
|
render: () => h(App)
|
||||||
});
|
});
|
||||||
|
app.config.globalProperties.supportedImageTypes = supportedImageTypes;
|
||||||
|
|
||||||
|
|
||||||
app.use(Vue3Sanitize, defaultOptions);
|
app.use(Vue3Sanitize, defaultOptions);
|
||||||
|
|
||||||
app.config.productionTip = false
|
app.config.productionTip = false
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ export class AttachmentManager {
|
||||||
|
|
||||||
private async prepareUpload(attachment: Attachment, room: KeanuRoom): Promise<Attachment> {
|
private async prepareUpload(attachment: Attachment, room: KeanuRoom): Promise<Attachment> {
|
||||||
const file = attachment.file;
|
const file = attachment.file;
|
||||||
if (file.type.startsWith("image/")) {
|
if (utils.isSupportedImageType(file.type)) {
|
||||||
let url = URL.createObjectURL(file);
|
let url = URL.createObjectURL(file);
|
||||||
attachment.src = url;
|
attachment.src = url;
|
||||||
if (attachment.src) {
|
if (attachment.src) {
|
||||||
|
|
|
||||||
|
|
@ -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_WIDTH = 640;
|
||||||
export const THUMBNAIL_MAX_HEIGHT = 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
|
// Install extended localized format
|
||||||
dayjs.extend(localizedFormat);
|
dayjs.extend(localizedFormat);
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
@ -437,7 +448,7 @@ class Util {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.type.startsWith("image/")) {
|
if (this.isSupportedImageType(file.type)) {
|
||||||
msgtype = "m.image";
|
msgtype = "m.image";
|
||||||
|
|
||||||
// Generate thumbnail?
|
// Generate thumbnail?
|
||||||
|
|
@ -940,7 +951,7 @@ class Util {
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
if (file.type.startsWith("image/")) {
|
if (this.isSupportedImageType(file.type)) {
|
||||||
try {
|
try {
|
||||||
var image = e.target.result;
|
var image = e.target.result;
|
||||||
|
|
||||||
|
|
@ -1236,6 +1247,10 @@ class Util {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isSupportedImageType(mime) {
|
||||||
|
return supportedImageTypes.some(prefix => mime.startsWith(prefix));
|
||||||
|
}
|
||||||
|
|
||||||
isMobileOrTabletBrowser() {
|
isMobileOrTabletBrowser() {
|
||||||
// Regular expression to match common mobile and tablet browser user agent strings
|
// 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;
|
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