This commit is contained in:
Timothy Jaeryang Baek committed 2026-12-03 00:04:48 +04:00
1 parent 792dcb2ff9
commit 0c48ec6daa
3 files changed
+37 -7

No files matched your search

+27 -5
View File
@@ -20,6 +20,7 @@
import Textarea from './common/Textarea.svelte';
import { normalizeTags } from '$lib/utils/tags';
import { compressImage } from '$lib/utils';
import { uploadFile } from '$lib/apis/files';
import { WEBUI_BASE_URL } from '$lib/constants';
export let onSubmit: Function = () => {};
@@ -61,6 +62,12 @@
let profileImageUrl = '';
let profileImageInput: HTMLInputElement;
const profileImageTypes = ['image/png', 'image/jpeg', 'image/webp', 'image/gif'];
// Stored as a link to the uploaded file, like model profile images.
$: profileImageSrc = profileImageUrl
? profileImageUrl.startsWith('/')
? `${WEBUI_BASE_URL}${profileImageUrl}`
: profileImageUrl
: `${WEBUI_BASE_URL}/static/favicon.png`;
const profileImageHandler = async (event: Event) => {
const input = event.currentTarget as HTMLInputElement;
@@ -248,6 +255,25 @@
}
}
if (profileImageUrl.startsWith('data:')) {
const blob = await (await fetch(profileImageUrl)).blob();
const uploaded = await uploadFile(
localStorage.token,
new File([blob], `profile.${blob.type.split('/')[1]}`, { type: blob.type }),
null,
false,
false
).catch((error) => {
toast.error(`${error}`);
return null;
});
if (!uploaded?.id) {
loading = false;
return;
}
profileImageUrl = `/api/v1/files/${uploaded.id}/content`;
}
// remove trailing slash from url
url = url.replace(/\/$/, '');
@@ -421,11 +447,7 @@
aria-label={$i18n.t('Upload')}
on:click={() => profileImageInput.click()}
>
<img
src={profileImageUrl || `${WEBUI_BASE_URL}/static/favicon.png`}
alt=""
class="size-full object-cover"
/>
<img src={profileImageSrc} alt="" class="size-full object-cover" />
</button>
</Tooltip>
{#if profileImageUrl}
@@ -48,7 +48,11 @@
<div class="group/setting-row flex w-full items-center gap-1.5 text-xs">
<img
src={config?.profile_image_url || `${WEBUI_BASE_URL}/static/favicon.png`}
src={config?.profile_image_url
? config.profile_image_url.startsWith('/')
? `${WEBUI_BASE_URL}${config.profile_image_url}`
: config.profile_image_url
: `${WEBUI_BASE_URL}/static/favicon.png`}
alt=""
class="size-5 shrink-0 rounded-full object-cover"
class:opacity-50={!(config?.enable ?? true)}
@@ -45,7 +45,11 @@
<div class="group/setting-row flex w-full gap-2 items-center text-xs">
<img
src={config?.profile_image_url || `${WEBUI_BASE_URL}/static/favicon.png`}
src={config?.profile_image_url
? config.profile_image_url.startsWith('/')
? `${WEBUI_BASE_URL}${config.profile_image_url}`
: config.profile_image_url
: `${WEBUI_BASE_URL}/static/favicon.png`}
alt=""
class="size-5 shrink-0 rounded-full object-cover"
class:opacity-50={!(config?.enable ?? true)}