add .tiff as supported image format
This commit is contained in:
parent
9eb9fbe3a5
commit
017d9be45a
3 changed files with 26 additions and 12 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from glob import glob
|
||||||
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from glob import glob
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
|
|
@ -379,11 +380,13 @@ actions.register(sortDocuments, cache=False)
|
||||||
def file(request, id, name=None):
|
def file(request, id, name=None):
|
||||||
document = get_document_or_404_json(request, id)
|
document = get_document_or_404_json(request, id)
|
||||||
accept = request.headers.get("Accept")
|
accept = request.headers.get("Accept")
|
||||||
|
mime_type = mimetypes.guess_type(document.file.path)[0]
|
||||||
|
mime_type = 'image/%s' % document.extension
|
||||||
if accept and 'image/' in accept and document.extension in (
|
if accept and 'image/' in accept and document.extension in (
|
||||||
'webp', 'heif', 'heic', 'avif'
|
'webp', 'heif', 'heic', 'avif', 'tiff'
|
||||||
) and document.extension not in accept:
|
) and mime_type not in accept:
|
||||||
image_size = max(document.width, document.height)
|
image_size = max(document.width, document.height)
|
||||||
return HttpFileResponse(document.thumbnail(image_size))
|
return HttpFileResponse(document.thumbnail(image_size, accept=accept))
|
||||||
return HttpFileResponse(document.file.path)
|
return HttpFileResponse(document.file.path)
|
||||||
|
|
||||||
def thumbnail(request, id, size=256, page=None):
|
def thumbnail(request, id, size=256, page=None):
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ pandora.ui.uploadDocumentDialog = function(options, callback) {
|
||||||
existingFiles = [],
|
existingFiles = [],
|
||||||
uploadFiles = [],
|
uploadFiles = [],
|
||||||
|
|
||||||
supportedExtensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png', 'webp', 'heic', 'heif', 'avif'],
|
|
||||||
|
|
||||||
filename,
|
filename,
|
||||||
|
|
||||||
ids = [],
|
ids = [],
|
||||||
|
|
@ -72,7 +70,7 @@ pandora.ui.uploadDocumentDialog = function(options, callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Ox.every(extensions, function(extension) {
|
if (!Ox.every(extensions, function(extension) {
|
||||||
return Ox.contains(supportedExtensions, extension)
|
return Ox.contains(pandora.documentExtensions, extension)
|
||||||
})) {
|
})) {
|
||||||
return errorDialog(
|
return errorDialog(
|
||||||
Ox._('Supported file types are GIF, JPG, PNG and PDF.')
|
Ox._('Supported file types are GIF, JPG, PNG and PDF.')
|
||||||
|
|
|
||||||
|
|
@ -420,13 +420,28 @@ pandora.createLinks = function($element) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pandora.imageExtensions = [
|
||||||
|
'avif',
|
||||||
|
'gif',
|
||||||
|
'heic',
|
||||||
|
'heif',
|
||||||
|
'jpeg',
|
||||||
|
'jpg',
|
||||||
|
'png',
|
||||||
|
'tiff',
|
||||||
|
'webp'
|
||||||
|
];
|
||||||
|
|
||||||
|
pandora.documentExtensions = [
|
||||||
|
'pdf', /* 'epub', 'txt', */
|
||||||
|
].concat(pandora.imageExtensions);
|
||||||
|
|
||||||
pandora.uploadDroppedFiles = function(files) {
|
pandora.uploadDroppedFiles = function(files) {
|
||||||
var documentExtensions = ['pdf', /* 'epub', 'txt', */ 'png', 'gif', 'jpg', 'jpeg', 'webp', 'heic', 'heif', 'avif'];
|
|
||||||
files = Ox.map(files, function(file) { return file });
|
files = Ox.map(files, function(file) { return file });
|
||||||
|
|
||||||
if (files.every(function(file) {
|
if (files.every(function(file) {
|
||||||
var extension = file.name.split('.').pop().toLowerCase()
|
var extension = file.name.split('.').pop().toLowerCase()
|
||||||
return Ox.contains(documentExtensions, extension)
|
return Ox.contains(pandora.documentExtensions, extension)
|
||||||
})) {
|
})) {
|
||||||
pandora.ui.uploadDocumentDialog({
|
pandora.ui.uploadDocumentDialog({
|
||||||
files: files
|
files: files
|
||||||
|
|
@ -2132,9 +2147,7 @@ pandora.getSpan = function(state, val, callback) {
|
||||||
} else {
|
} else {
|
||||||
state.span = val;
|
state.span = val;
|
||||||
}
|
}
|
||||||
} else if (Ox.contains([
|
} else if (Ox.contains(pandora.imageExtensions, extension)) {
|
||||||
'gif', 'gif', 'jpg', 'png', 'webp', 'heic', 'heif', 'avif'
|
|
||||||
], extension)) {
|
|
||||||
values = val.split(',');
|
values = val.split(',');
|
||||||
if (values.length == 4) {
|
if (values.length == 4) {
|
||||||
state.span = values.map(function(number, index) {
|
state.span = values.map(function(number, index) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue