fix, wip: don't show preview for non-image fragments

This commit is contained in:
Tomáš Mládek 2023-04-23 22:57:52 +02:00
parent ddb7af116b
commit ee2c1fde94

View file

@ -12,8 +12,13 @@
$: objectAddress = String($entity?.get("ANNOTATES") || "");
$: imageFragment = ["x=", "y=", "w=", "h="].every((q) =>
String($entity?.get("W3C_FRAGMENT_SELECTOR")).includes(q)
);
let imageLoaded = false;
$: imageLoaded && dispatch("loaded");
$: if ($entity && !imageFragment) imageLoaded = true;
</script>
<div class="fragment-viewer">
@ -21,17 +26,19 @@
<Spinner />
{/if}
{#if $entity}
<img
class="preview-image"
class:imageLoaded
src="{API_URL}/{detail ? 'raw' : 'thumb'}/{objectAddress}#{$entity?.get(
'W3C_FRAGMENT_SELECTOR'
)}"
use:xywh
alt={address}
on:load={() => (imageLoaded = true)}
draggable="false"
/>
{#if imageFragment}
<img
class="preview-image"
class:imageLoaded
src="{API_URL}/{detail ? 'raw' : 'thumb'}/{objectAddress}#{$entity?.get(
'W3C_FRAGMENT_SELECTOR'
)}"
use:xywh
alt={address}
on:load={() => (imageLoaded = true)}
draggable="false"
/>
{/if}
{/if}
</div>