open-webui/src/lib/components/common/Image.svelte

24 lines
530 B
Svelte
Raw Normal View History

2024-02-23 02:49:34 +00:00
<script lang="ts">
2024-03-09 01:38:10 +00:00
import { WEBUI_BASE_URL } from '$lib/constants';
2024-02-23 02:49:34 +00:00
import ImagePreview from './ImagePreview.svelte';
export let src = '';
export let alt = '';
2024-03-09 01:38:10 +00:00
let _src = '';
$: _src = src.startsWith('/') ? `${WEBUI_BASE_URL}${src}` : src;
2024-02-23 02:49:34 +00:00
let showImagePreview = false;
</script>
2024-03-09 01:38:10 +00:00
<ImagePreview bind:show={showImagePreview} src={_src} {alt} />
2024-02-23 02:49:34 +00:00
<button
on:click={() => {
console.log('image preview');
showImagePreview = true;
}}
>
2024-03-09 01:38:10 +00:00
<img src={_src} {alt} class=" max-h-96 rounded-lg" draggable="false" />
2024-02-23 02:49:34 +00:00
</button>