{#if loaded} { allowNavigation = true; afterDiscard?.(); }} />
{#if onBack} {/if} {#if edit && model?.version_id && !readOnly} {/if} {#if !historical && !readOnly}
(showAccessControlModal = true)} />
{/if}
{#if selectingVersion}
{:else if selectedVersion}
{#key selectedVersion.id} {/key}
{/if}
{ let reader = new FileReader(); reader.onload = (event) => { let originalImageUrl = `${event.target?.result}`; // For animated formats (gif, webp), skip resizing to preserve animation const fileType = (inputFiles[0] as any)?.['type']; if (fileType === 'image/gif' || fileType === 'image/webp') { info.meta.profile_image_url = originalImageUrl; inputFiles = null; filesInputElement.value = ''; return; } const img = new Image(); img.src = originalImageUrl; img.onload = function () { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); // Calculate the aspect ratio of the image const aspectRatio = img.width / img.height; // Calculate the new width and height to fit within 100x100 let newWidth, newHeight; if (aspectRatio > 1) { newWidth = 250 * aspectRatio; newHeight = 250; } else { newWidth = 250; newHeight = 250 / aspectRatio; } // Set the canvas size canvas.width = 250; canvas.height = 250; // Calculate the position to center the image const offsetX = (250 - newWidth) / 2; const offsetY = (250 - newHeight) / 2; // Draw the image on the canvas ctx.drawImage(img, offsetX, offsetY, newWidth, newHeight); // Get the base64 representation of the compressed image const compressedSrc = canvas.toDataURL('image/webp', 0.8); // Display the compressed image info.meta.profile_image_url = compressedSrc; inputFiles = null; filesInputElement.value = ''; }; }; if ( inputFiles && inputFiles.length > 0 && ['image/gif', 'image/webp', 'image/jpeg', 'image/png', 'image/svg+xml'].includes( (inputFiles[0] as any)?.['type'] ) ) { reader.readAsDataURL(inputFiles[0]); } else { console.log(`Unsupported File Type '${(inputFiles[0] as any)?.['type']}'.`); inputFiles = null; } }} /> {#if !edit || (edit && model)}
{ submitHandler(); }} >
{#if info.meta.profile_image_url && info.meta.profile_image_url !== `${WEBUI_BASE_URL}/static/favicon.png`} {/if}
{#if editingLocale} setLocalizedField('name', (e.currentTarget as HTMLInputElement).value)} /> {:else} {/if}
{#if editingLocale}
{#if localizedField('name')} {/if}
{/if}
{#if preset}
{$i18n.t('Base Model (From)')}
{/if} {#if preset || info.base_model_id}
{$i18n.t('Background Image')}
{#if backgroundPreview || info.meta.background_image_url} {/if}
{ const selected = backgroundInput.files?.[0]; backgroundInput.value = ''; if (!selected || loading) return; loading = true; const candidate = URL.createObjectURL(selected); try { if ( !['image/png', 'image/jpeg', 'image/webp', 'image/gif'].includes( selected.type ) ) { throw new Error( $i18n.t('Background image must be PNG, JPEG, WebP, or GIF.') ); } if (selected.size > 5 * 1024 * 1024) throw new Error($i18n.t('Background image must be at most 5 MiB.')); const image = new Image(); image.src = candidate; await image.decode(); if (image.naturalWidth * image.naturalHeight > 25_000_000) { throw new Error( $i18n.t('Background image must be at most 25 megapixels.') ); } clearBackgroundPreview(); backgroundPreview = candidate; backgroundFile = selected; } catch (error) { URL.revokeObjectURL(candidate); toast.error( error instanceof Error ? error.message : $i18n.t('Invalid background image.') ); } finally { loading = false; } }} /> {#if backgroundPreview || info.meta.background_image_url} {$i18n.t('Background {/if}

{$i18n.t('PNG, JPEG, WebP, or GIF. Up to 5 MiB and 25 megapixels.')}

{/if}
{editingLocale ? $i18n.t('Description ({{language}})', { language: editingLocaleLabel || editingLocale }) : $i18n.t('Description')}
{#if editingLocale}
{#if localizedField('description')} {/if}
{:else} {/if}
{#if editingLocale}