mirror of
https://github.com/slynn1324/tinypin.git
synced 2026-01-22 18:16:28 +00:00
Add WebP support
This commit is contained in:
parent
fed01f948b
commit
0cc19c48c0
2 changed files with 8 additions and 4 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue