mirror of
https://github.com/simonw/datasette.git
synced 2026-07-08 08:34:42 +02:00
Use image load events for BLOB previews
This commit is contained in:
parent
81d6ee69cd
commit
ae26c3372a
1 changed files with 4 additions and 8 deletions
|
|
@ -4116,8 +4116,6 @@ function updateRowEditBinaryPreview(wrapper, encoded, byteLength) {
|
|||
image.alt = "";
|
||||
var objectUrl = URL.createObjectURL(new Blob([bytes], { type: mimeType }));
|
||||
wrapper._rowEditBinaryPreviewUrl = objectUrl;
|
||||
image.src = objectUrl;
|
||||
preview.appendChild(image);
|
||||
|
||||
var showPreview = function () {
|
||||
if (wrapper._rowEditBinaryPreviewUrl === objectUrl) {
|
||||
|
|
@ -4131,12 +4129,10 @@ function updateRowEditBinaryPreview(wrapper, encoded, byteLength) {
|
|||
preview.textContent = "";
|
||||
}
|
||||
};
|
||||
if (image.decode) {
|
||||
image.decode().then(showPreview).catch(hidePreview);
|
||||
} else {
|
||||
image.onload = showPreview;
|
||||
image.onerror = hidePreview;
|
||||
}
|
||||
image.onload = showPreview;
|
||||
image.onerror = hidePreview;
|
||||
image.src = objectUrl;
|
||||
preview.appendChild(image);
|
||||
}
|
||||
|
||||
function updateRowEditBinaryDisplay(wrapper, control, fileName) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue