From cdbe4ed8ebd26b06b9a77c666b7ba0dbc77ee4d5 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 22 Jan 2020 17:15:37 +0100 Subject: [PATCH] Only allow image upload in onlyoffice --- www/common/onlyoffice/inner.js | 6 +++++- www/filepicker/inner.js | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 1269039a8..53ff82307 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -831,7 +831,11 @@ define([ APP.AddImageErrorCallback = cb2; common.openFilePicker({ types: ['file'], - where: ['root'] + where: ['root'], + filter: { + fileType: ['image/'] + } + }); }; diff --git a/www/filepicker/inner.js b/www/filepicker/inner.js index aba736916..8ee5a56f4 100644 --- a/www/filepicker/inner.js +++ b/www/filepicker/inner.js @@ -111,6 +111,16 @@ define([ //If file, display the upload button if (types.indexOf('file') !== -1 && common.isLoggedIn()) { + var f = (filters && filters.filter) || {}; + delete data.accept; + if (f.fileType) { + data.accept = f.fileType.map(function (val) { + if (/^[a-z]+\/$/.test(val)) { + val += '*'; + } + return val; + }); + } $filter.append(common.createButton('upload', false, data)); }