From 0cc19c48c0963045167497f31a8d4507e34b58ea Mon Sep 17 00:00:00 2001 From: Jeff Rector Date: Wed, 1 Feb 2023 07:38:20 -0500 Subject: [PATCH] Add WebP support --- client/app.js | 6 ++++-- client/components/addpin.js | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/app.js b/client/app.js index d167d03..a287169 100644 --- a/client/app.js +++ b/client/app.js @@ -103,6 +103,8 @@ app.addSetter("app.uploadDroppedFiles", async (data, evt) => { let boardId = store.data.board.id; + const supportedTypes = ["image/jpeg","image/png","image/webp"]; + if ( boardId ){ let hasFiles = event.dataTransfer.types.find(i => i == "Files") == "Files"; if ( hasFiles ){ @@ -115,9 +117,9 @@ app.addSetter("app.uploadDroppedFiles", async (data, evt) => { if ( evt.dataTransfer.items[i].kind === "file" ){ let file = evt.dataTransfer.items[i].getAsFile(); - if ( file.type != "image/jpeg" && file.type != "image/png" ){ + if ( !supportedTypes.includes(file.type)){ - window.alert("Unsupported file type. JPEG and PNG images are supported."); + window.alert("Unsupported file type. JPEG, PNG, and WebP images are supported."); console.log("Unsupported file type: " + file.type); return; diff --git a/client/components/addpin.js b/client/components/addpin.js index 1b13a3b..f5e54fc 100644 --- a/client/components/addpin.js +++ b/client/components/addpin.js @@ -142,10 +142,12 @@ app.addSetter('addPinModal.fileChosen', (data, target) => { let file = target.files[0]; + const supportedTypes = ["image/jpeg","image/png","image/webp"]; + // check type - if ( file.type != "image/jpeg" && file.type != "image/png" ){ + if ( !supportedTypes.includes(file.type)){ - window.alert("Unsupported file type. JPEG and PNG images are supported."); + window.alert("Unsupported file type. JPEG, PNG and WebP images are supported."); console.log("Unsupported file type: " + file.type); document.getElementById("fileInput").value = "";