mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 01:46:18 -05:00
Handling when file_group or file is sent to path getters.
This commit is contained in:
parent
7e23e2cfff
commit
5bd1e39f0e
1 changed files with 20 additions and 7 deletions
|
|
@ -10,16 +10,28 @@ import {
|
|||
ModalHeader
|
||||
} from "semantic-ui-react";
|
||||
|
||||
function getMediaPathURL(path) {
|
||||
return `/media/${encodeURIComponent(path['path'])}`;
|
||||
function getMediaPathURL(file) {
|
||||
if (file['primary_path']) {
|
||||
return `/media/${encodeURIComponent(file['primary_path'])}`;
|
||||
} else {
|
||||
return `/media/${encodeURIComponent(file['path'])}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getDownloadPathURL(path) {
|
||||
return `/download/${encodeURIComponent(path['path'])}`;
|
||||
function getDownloadPathURL(file) {
|
||||
if (file['primary_path']) {
|
||||
return `/download/${encodeURIComponent(file['primary_path'])}`;
|
||||
} else {
|
||||
return `/download/${encodeURIComponent(file['path'])}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getEpubViewerURL(path) {
|
||||
return `/epub.html?url=download/${encodeURIComponent(path['path'])}`;
|
||||
function getEpubViewerURL(file) {
|
||||
if (file['primary_path']) {
|
||||
return `/epub.html?url=download/${encodeURIComponent(file['primary_path'])}`;
|
||||
} else {
|
||||
return `/epub.html?url=download/${encodeURIComponent(file['path'])}`;
|
||||
}
|
||||
}
|
||||
|
||||
function getIframeModal(path) {
|
||||
|
|
@ -143,7 +155,8 @@ export function FilePreviewWrapper({children}) {
|
|||
}
|
||||
|
||||
if (previewFile && !_.isEmpty(previewFile)) {
|
||||
const {mimetype, size, path} = previewFile;
|
||||
const {mimetype, size} = previewFile;
|
||||
const path = previewFile['primary_path'] || previewFile['path'];
|
||||
const lowerPath = path.toLowerCase();
|
||||
console.debug(`useFilePreview path=${previewFile['path']} mimetype=${mimetype}`);
|
||||
const url = getMediaPathURL(previewFile);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue