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:
@@ -2615,9 +2615,20 @@
|
|||||||
|
|
||||||
// Show thumbnail in scan photo preview
|
// Show thumbnail in scan photo preview
|
||||||
const reader = new FileReader();
|
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) {
|
reader.onload = async function(e) {
|
||||||
const thumb = document.getElementById('scanPhotoThumb');
|
const thumb = document.getElementById('scanPhotoThumb');
|
||||||
if (thumb) thumb.src = e.target.result;
|
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');
|
const preview = document.getElementById('scanPhotoPreview');
|
||||||
if (preview) preview.style.display = 'block';
|
if (preview) preview.style.display = 'block';
|
||||||
|
|||||||
Reference in New Issue
Block a user