diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 157513e00..cdc27768c 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -275,6 +275,7 @@ function copyImageFromClipboard(e) { if (!clipboardData) { return; } if (clipboardData.types.some(function(t){ return /^text\/plain$/.test(t); })) { return; } + var pixelDensity = Math.round(window.devicePixelRatio); var files = clipboardData.files for (var i = 0 ; i < files.length ; i++) { var file = files[i]; @@ -286,8 +287,13 @@ function copyImageFromClipboard(e) { + ('0'+date.getDate()).slice(-2) + ('0'+date.getHours()).slice(-2) + ('0'+date.getMinutes()).slice(-2) - + '-' + randomKey(5).toLocaleLowerCase() - + '.' + file.name.split('.').pop(); + + '-' + randomKey(5).toLocaleLowerCase(); + // pixel density descriptor (e.g. @2x) + if (pixelDensity >= 2) { + filename += '@' + pixelDensity + 'x'; + } + // file extension + filename += '.' + file.name.split('.').pop(); // get input file in the closest form var inputEl = $(this).closest("form").find('input:file.filedrop');