31 lines
943 B
JavaScript
31 lines
943 B
JavaScript
export function imgurl(channel, record) {
|
|
if (record._file.mime === "image/svg+xml") {
|
|
return fileurl(channel, record);
|
|
}
|
|
return channel.disks[record._file.disk] + `/thumbs/${record._file.path}`;
|
|
}
|
|
|
|
export function fileurl(channel, record) {
|
|
return channel.disks[record._file.disk] + `/${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.disks[record._file.disk] + `/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;
|
|
}
|