diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-08-11 19:26:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-11 19:26:05 +0300 |
commit | 2859457600a29ae783f165d7edd8825f40859f02 (patch) | |
tree | a8ca7378d1a9c38db66de26b00fb04de0aa33993 /client/lib/utils.js | |
parent | 30680f13d67e31a551511b9e6e24d807a2c8064d (diff) | |
parent | 4857bce5d953ba3299a1de4c1894a96913d4d857 (diff) | |
download | wekan-2859457600a29ae783f165d7edd8825f40859f02.tar.gz wekan-2859457600a29ae783f165d7edd8825f40859f02.tar.bz2 wekan-2859457600a29ae783f165d7edd8825f40859f02.zip |
Merge pull request #2608 from whowillcare/master
Make image upload in summernote as attachment to wekan board instead of base64 string and more
Diffstat (limited to 'client/lib/utils.js')
-rw-r--r-- | client/lib/utils.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/client/lib/utils.js b/client/lib/utils.js index f81e691c..81835929 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -26,6 +26,31 @@ Utils = { MAX_IMAGE_PIXEL: Meteor.settings.public.MAX_IMAGE_PIXEL, COMPRESS_RATIO: Meteor.settings.public.IMAGE_COMPRESS_RATIO, + processUploadedAttachment(card, fileObj, callback) { + const next = attachment => { + if (typeof callback === 'function') { + callback(attachment); + } + }; + if (!card) { + return next(); + } + const file = new FS.File(fileObj); + if (card.isLinkedCard()) { + file.boardId = Cards.findOne(card.linkedId).boardId; + file.cardId = card.linkedId; + } else { + file.boardId = card.boardId; + file.swimlaneId = card.swimlaneId; + file.listId = card.listId; + file.cardId = card._id; + } + file.userId = Meteor.userId(); + if (file.original) { + file.original.name = fileObj.name; + } + return next(Attachments.insert(file)); + }, shrinkImage(options) { // shrink image to certain size const dataurl = options.dataurl, |