rich editor files

This commit is contained in:
2024-08-18 17:23:18 +03:00
parent ec15f21e67
commit 5d6869c118
20 changed files with 966 additions and 64 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
>
<img
class="rounded w-100"
src={imgurl(record)}
src={imgurl(channel,record)}
alt={record._file.path}
/>
</a>
+25 -7
View File
@@ -1,15 +1,33 @@
import {getContext} from "svelte";
export function imgurl(record) {
export function imgurl(channel,record) {
if(record._file.mime === "image/svg+xml"){
return fileurl(record);
if (record._file.mime === "image/svg+xml") {
return fileurl(channel, record);
}
const channel = getContext("channel")
return channel.filesUrl + `/thumbs/${record._file.path}`;
}
export function fileurl(record) {
const channel = getContext("channel")
export function fileurl(channel, record) {
return channel.filesUrl + `/${record._file.path}`;
}
export function htmlurl(channel,record, preset) {
let html = "";
let url = fileurl(channel,record)
if (record._file.width > 0) {
let presetUrl = url;
if (preset) {
presetUrl = channel.filesUrl + `/templates/${preset}/${record._file.path}`;
}
html = `<img src="${presetUrl}" alt="${record._file.path}" />`
} else if (record._file.mime === "image/svg+xml") {
html = `<img src="${url}" alt="${record._file.path}"/>`
} else {
html = `<a href="${url}">${record._file.originalName}</a>`
}
return html;
}