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

26 lines
551 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-08-05 15:12:41 +00:00
<div>
2024-08-04 16:14:17 +00:00
<button
on:click={() => {
showImagePreview = true;
}}
2024-08-05 15:12:41 +00:00
class="w-full"
2024-08-04 16:14:17 +00:00
>
<img src={_src} {alt} class=" max-h-96 rounded-lg" draggable="false" data-cy="image" />
</button>
</div>
2024-08-04 23:03:22 +00:00
<ImagePreview bind:show={showImagePreview} src={_src} {alt} />