Fix image uploads and reduce flyer request sizes

This commit is contained in:
kai
2026-08-27 07:34:45 +02:00
parent 41b2c5cd61
commit fd8c216cc8
4 changed files with 96 additions and 5 deletions
+2 -2
View File
@@ -213,10 +213,10 @@ if (profileForm) {
context.imageSmoothingQuality = "high";
context.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
bitmap.close();
const blob = await new Promise(resolve => canvas.toBlob(resolve, "image/webp", .86));
const blob = await new Promise(resolve => canvas.toBlob(resolve, "image/jpeg", .88));
if (!blob) throw new Error("Bild konnte nicht verarbeitet werden");
const transfer = new DataTransfer();
transfer.items.add(new File([blob], "profilbild.webp", {type: "image/webp"}));
transfer.items.add(new File([blob], "profilbild.jpg", {type: "image/jpeg"}));
input.files = transfer.files;
profileForm.dataset.optimized = "true";
status.textContent = `Optimiert: ${Math.ceil(blob.size / 1024)} KB wird hochgeladen …`;