Spaces:
Sleeping
Sleeping
File size: 850 Bytes
366dac3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | const imageInput = document.querySelector("#imageInput");
const imageUrlInput = document.querySelector("#imageUrlInput");
const previewCard = document.querySelector("#previewCard");
const imagePreview = document.querySelector("#imagePreview");
function showPreview(src) {
if (!previewCard || !imagePreview || !src) return;
imagePreview.src = src;
previewCard.hidden = false;
}
if (imageInput) {
imageInput.addEventListener("change", () => {
const file = imageInput.files && imageInput.files[0];
if (!file) return;
showPreview(URL.createObjectURL(file));
if (imageUrlInput) imageUrlInput.value = "";
});
}
if (imageUrlInput) {
imageUrlInput.addEventListener("input", () => {
const value = imageUrlInput.value.trim();
if (!value) return;
showPreview(value);
if (imageInput) imageInput.value = "";
});
}
|