Add WebP support

This commit is contained in:
Jeff Rector 2023-02-01 07:38:20 -05:00
parent fed01f948b
commit 0cc19c48c0
2 changed files with 8 additions and 4 deletions

View file

@ -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;

View file

@ -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 = "";