enh: prepend image filename with prompt

This commit is contained in:
Timothy J. Baek 2024-09-18 01:04:20 +02:00
parent 63b3076d64
commit 614c219010
2 changed files with 4 additions and 4 deletions

View File

@ -344,7 +344,7 @@
{#each message.files as file}
<div>
{#if file.type === 'image'}
<Image src={file.url} />
<Image src={file.url} alt={message.content} />
{/if}
</div>
{/each}

View File

@ -9,14 +9,14 @@
let previewElement = null;
const downloadImage = (url, filename) => {
const downloadImage = (url, filename, prefixName = '') => {
fetch(url)
.then((response) => response.blob())
.then((blob) => {
const objectUrl = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = objectUrl;
link.download = filename;
link.download = `${prefixName}${filename}`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
@ -87,7 +87,7 @@
<button
class=" p-5"
on:click={() => {
downloadImage(src, src.substring(src.lastIndexOf('/') + 1));
downloadImage(src, src.substring(src.lastIndexOf('/') + 1), alt);
}}
>
<svg