gallery upload: add FileReader + img error handlers

- reader.onerror: shows error message on file read failure
- img.onerror: detects unsupported image formats (HEIC, RAW)
- Shows clear feedback: 'unsupported format' or 'format not supported'
- Helps diagnose gallery upload issues
This commit is contained in:
2026-05-21 14:44:02 -04:00
parent 6403699486
commit 78c3c19ce4
+11
View File
@@ -2615,9 +2615,20 @@
// Show thumbnail in scan photo preview
const reader = new FileReader();
reader.onerror = function() {
const ocrEl = document.getElementById('scanOcrResult');
if (ocrEl) ocrEl.textContent = '❌ Could not read file — unsupported format or corrupted. Try a JPEG screenshot instead.';
const preview = document.getElementById('scanPhotoPreview');
if (preview) preview.style.display = 'block';
};
reader.onload = async function(e) {
const thumb = document.getElementById('scanPhotoThumb');
if (thumb) thumb.src = e.target.result;
thumb.onerror = function() {
const ocrEl = document.getElementById('scanOcrResult');
if (ocrEl) ocrEl.textContent = '❌ Image format not supported in browser. Try a JPEG screenshot.';
thumb.style.display = 'none';
};
const preview = document.getElementById('scanPhotoPreview');
if (preview) preview.style.display = 'block';