image-path.svelte (665B)
1 <script lang="ts"> 2 import { get_context, ImageBlob, ImageSrc } from "@radroots/apps-lib"; 3 import type { IImagePath } from "@radroots/apps-lib"; 4 import type { LibContext } from "$lib/types/context"; 5 6 const { lc_img_bin } = get_context<LibContext>(`lib`); 7 let { basis }: { basis: IImagePath } = $props(); 8 9 const img_path = $derived(basis.path); 10 </script> 11 12 {#if img_path} 13 {@const is_bin = img_path.startsWith(`file:`)} 14 15 {#if is_bin} 16 {#await lc_img_bin(img_path) then data} 17 <ImageBlob basis={{ data, ...basis }} /> 18 {/await} 19 {:else} 20 <ImageSrc basis={{ src: img_path, ...basis }} /> 21 {/if} 22 {/if}