mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Fix missing asset preview for static images
This commit is contained in:
@@ -944,6 +944,10 @@ function isGifAsset(asset) {
|
|||||||
return asset?.mediaType?.toLowerCase() === "image/gif";
|
return asset?.mediaType?.toLowerCase() === "image/gif";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCachedSource(element) {
|
||||||
|
return element?.dataset?.sourceUrl || element?.src || null;
|
||||||
|
}
|
||||||
|
|
||||||
function isDrawable(element) {
|
function isDrawable(element) {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1070,10 +1074,11 @@ function autoStartAudio(asset) {
|
|||||||
|
|
||||||
function ensureMedia(asset) {
|
function ensureMedia(asset) {
|
||||||
const cached = mediaCache.get(asset.id);
|
const cached = mediaCache.get(asset.id);
|
||||||
if (cached && cached.src !== asset.url) {
|
const cachedSource = getCachedSource(cached);
|
||||||
|
if (cached && cachedSource !== asset.url) {
|
||||||
clearMedia(asset.id);
|
clearMedia(asset.id);
|
||||||
}
|
}
|
||||||
if (cached && cached.src === asset.url) {
|
if (cached && cachedSource === asset.url) {
|
||||||
applyMediaSettings(cached, asset);
|
applyMediaSettings(cached, asset);
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
@@ -1097,6 +1102,7 @@ function ensureMedia(asset) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const element = isVideoAsset(asset) ? document.createElement("video") : new Image();
|
const element = isVideoAsset(asset) ? document.createElement("video") : new Image();
|
||||||
|
element.dataset.sourceUrl = asset.url;
|
||||||
element.crossOrigin = "anonymous";
|
element.crossOrigin = "anonymous";
|
||||||
if (isVideoElement(element)) {
|
if (isVideoElement(element)) {
|
||||||
element.loop = true;
|
element.loop = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user