fix: any image dropped or uploaded while card is showing always swaps background without clearing fields
This commit is contained in:
+14
-10
@@ -1098,22 +1098,26 @@ function processStandard(file) {
|
|||||||
reader.onload = e => {
|
reader.onload = e => {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
|
const cardIsShowing = outputSection.style.display && outputSection.style.display !== 'none';
|
||||||
|
if (cardIsShowing) {
|
||||||
|
currentImg = img;
|
||||||
|
clearStatus();
|
||||||
|
renderCard(img, readEditFields());
|
||||||
|
return;
|
||||||
|
}
|
||||||
EXIF.getData(img, function() {
|
EXIF.getData(img, function() {
|
||||||
const exif = EXIF.getAllTags(this);
|
const exif = EXIF.getAllTags(this);
|
||||||
const meta = extractMeta(exif);
|
const meta = extractMeta(exif);
|
||||||
const hasExif = !!(meta.camera || meta.aperture || meta.shutter || meta.iso || meta.focalLength);
|
const hasExif = !!(meta.camera || meta.aperture || meta.shutter || meta.iso || meta.focalLength);
|
||||||
if (!hasExif) {
|
|
||||||
currentImg = img;
|
|
||||||
clearStatus();
|
|
||||||
if (editPanel.style.display === 'none') populateEditFields({}, false);
|
|
||||||
const existingMeta = readEditFields();
|
|
||||||
renderCard(img, existingMeta);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentImg = img;
|
currentImg = img;
|
||||||
clearStatus();
|
clearStatus();
|
||||||
populateEditFields(meta, false);
|
if (hasExif) {
|
||||||
renderCard(img, meta);
|
populateEditFields(meta, false);
|
||||||
|
renderCard(img, meta);
|
||||||
|
} else {
|
||||||
|
if (editPanel.style.display === 'none') populateEditFields({}, false);
|
||||||
|
renderCard(img, readEditFields());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
img.onerror = () => showError('Could not decode this image. Try saving it as a JPEG or PNG first.');
|
img.onerror = () => showError('Could not decode this image. Try saving it as a JPEG or PNG first.');
|
||||||
|
|||||||
Reference in New Issue
Block a user