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

27 lines
606 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-08-20 15:03:20 +00:00
export let className = ' w-full';
2024-11-10 07:57:19 +00:00
export let imageClassName = 'rounded-lg';
2024-03-09 01:38:10 +00:00
2024-08-05 16:00:04 +00:00
let _src = '';
2024-03-09 01:38:10 +00:00
$: _src = src.startsWith('/') ? `${WEBUI_BASE_URL}${src}` : src;
2024-02-23 02:49:34 +00:00
let showImagePreview = false;
</script>
2024-08-06 23:55:37 +00:00
<button
class={className}
on:click={() => {
showImagePreview = true;
}}
>
2024-11-10 07:57:19 +00:00
<img src={_src} {alt} class={imageClassName} draggable="false" data-cy="image" />
2024-08-06 23:55:37 +00:00
</button>
2024-08-04 23:03:22 +00:00
<ImagePreview bind:show={showImagePreview} src={_src} {alt} />