mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
Ref: original & and use fileObj.meta
fileObj.meta is part of the ostrio:files API and be passed to the constructor. This is less hacky than trying tu update a persistet object after the fact.
This commit is contained in:
parent
16506e7a6a
commit
e702f17c7b
10 changed files with 124 additions and 159 deletions
|
|
@ -160,28 +160,23 @@ BlazeComponent.extendComponent({
|
|||
const currentCard = Utils.getCurrentCard();
|
||||
const MAX_IMAGE_PIXEL = Utils.MAX_IMAGE_PIXEL;
|
||||
const COMPRESS_RATIO = Utils.IMAGE_COMPRESS_RATIO;
|
||||
const insertImage = src => {
|
||||
const img = document.createElement('img');
|
||||
img.src = src;
|
||||
img.setAttribute('width', '100%');
|
||||
$summernote.summernote('insertNode', img);
|
||||
};
|
||||
const processUpload = function(file) {
|
||||
const uploader = Attachments.insert(
|
||||
{
|
||||
file,
|
||||
meta: Utils.getCommonAttachmentMetaFrom(card),
|
||||
chunkSize: 'dynamic',
|
||||
},
|
||||
false,
|
||||
);
|
||||
uploader.on('uploaded', (error, fileObj) => {
|
||||
uploader.on('uploaded', (error, fileRef) => {
|
||||
if (!error) {
|
||||
if (fileObj.isImage) {
|
||||
insertImage(
|
||||
`${location.protocol}//${location.host}${fileObj.path}`,
|
||||
);
|
||||
if (fileRef.isImage) {
|
||||
const img = document.createElement('img');
|
||||
img.src = fileRef.link();
|
||||
img.setAttribute('width', '100%');
|
||||
$summernote.summernote('insertNode', img);
|
||||
}
|
||||
Utils.addCommonMetaToAttachment(currentCard, fileObj);
|
||||
}
|
||||
});
|
||||
uploader.start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue