From: Marius Balteanu Date: Fri, 18 Mar 2022 17:43:21 +0000 (+0000) Subject: Use @clipboardData.files@ instead of @clipboardData.items@ to get the images from... X-Git-Tag: 5.0.0~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d6c0759db4f3322d18f970e558920b20aed552af;p=redmine.git Use @clipboardData.files@ instead of @clipboardData.items@ to get the images from the clipboard (#36013). git-svn-id: http://svn.redmine.org/redmine/trunk@21463 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 9380d1274..3155362fc 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -275,11 +275,10 @@ function copyImageFromClipboard(e) { if (!clipboardData) { return; } if (clipboardData.types.some(function(t){ return /^text\/plain$/.test(t); })) { return; } - var items = clipboardData.items - for (var i = 0 ; i < items.length ; i++) { - var item = items[i]; - if (item.type.indexOf("image") != -1) { - var blob = item.getAsFile(); + var files = clipboardData.files + for (var i = 0 ; i < files.length ; i++) { + var file = files[i]; + if (file.type.indexOf("image") != -1) { var date = new Date(); var filename = 'clipboard-' + date.getFullYear() @@ -288,9 +287,8 @@ function copyImageFromClipboard(e) { + ('0'+date.getHours()).slice(-2) + ('0'+date.getMinutes()).slice(-2) + '-' + randomKey(5).toLocaleLowerCase() - + '.' + blob.name.split('.').pop(); - var file = new Blob([blob], {type: blob.type}); - file.name = filename; + + '.' + file.name.split('.').pop(); + var inputEl = $('input:file.filedrop').first() handleFileDropEvent.target = e.target; addFile(inputEl, file, true);