From: Dan Brown Date: Tue, 7 Jun 2022 13:59:00 +0000 (+0100) Subject: Updated image drop handling to respect original file name X-Git-Tag: v22.06~1^2~17 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/3fe666f36a7642c7910e6e0dc2f44916931a00b1 Updated image drop handling to respect original file name Now uses the previously timestamp gen name as a backup to the original name. Aligns with the image manager upload which uses the original name where given. Closes #3470 --- diff --git a/resources/js/wysiwyg/drop-paste-handling.js b/resources/js/wysiwyg/drop-paste-handling.js index ace74dd33..0529f6b6c 100644 --- a/resources/js/wysiwyg/drop-paste-handling.js +++ b/resources/js/wysiwyg/drop-paste-handling.js @@ -60,13 +60,7 @@ async function uploadImageFile(file, pageId) { throw new Error(`Not an image file`); } - let ext = 'png'; - if (file.name) { - let fileNameMatches = file.name.match(/\.(.+)$/); - if (fileNameMatches.length > 1) ext = fileNameMatches[1]; - } - - const remoteFilename = "image-" + Date.now() + "." + ext; + const remoteFilename = file.name || `image-${Date.now()}.png`; const formData = new FormData(); formData.append('file', file, remoteFilename); formData.append('uploaded_to', pageId);