From 3fe666f36a7642c7910e6e0dc2f44916931a00b1 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 7 Jun 2022 14:59:00 +0100 Subject: [PATCH] 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 --- resources/js/wysiwyg/drop-paste-handling.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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);