diff --git a/frontend/src/components/dir-view-mode/dir-column-nav.js b/frontend/src/components/dir-view-mode/dir-column-nav.js index 30bac069c7..8cdb806705 100644 --- a/frontend/src/components/dir-view-mode/dir-column-nav.js +++ b/frontend/src/components/dir-view-mode/dir-column-nav.js @@ -251,27 +251,25 @@ class DirColumnNav extends React.Component { return Utils.imageCheck(item.object.name); }); - const useThumbnail = !this.props.currentRepoInfo.encrypted; + const repoEncrypted = this.props.currentRepoInfo.encrypted; + const repoID = this.props.repoID; let prepareItem = (item) => { const name = item.object.name; - const path = Utils.encodePath(Utils.joinPath(node.parentNode.path, name)); const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase(); const isGIF = fileExt === 'gif'; - - const repoID = this.props.repoID; - let src = ''; - if (useThumbnail && !isGIF) { - src = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`; + const src = `${siteRoot}repo/${repoID}/raw${path}`; + let thumbnail = ''; + if (repoEncrypted || isGIF) { + thumbnail = src; } else { - src = `${siteRoot}repo/${repoID}/raw${path}`; + thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`; } - return { - 'name': name, + name, + src, + thumbnail, 'url': `${siteRoot}lib/${repoID}/file${path}`, - 'src': src, - 'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`, 'node': items.find(item => item.path.split('/').pop() === name), 'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`, }; diff --git a/frontend/src/components/dirent-grid-view/dirent-grid-view.js b/frontend/src/components/dirent-grid-view/dirent-grid-view.js index 588ffff18c..973571acf6 100644 --- a/frontend/src/components/dirent-grid-view/dirent-grid-view.js +++ b/frontend/src/components/dirent-grid-view/dirent-grid-view.js @@ -583,14 +583,24 @@ class DirentGridView extends React.Component { prepareImageItem = (item) => { const name = item.name; const repoID = this.props.repoID; + const repoEncrypted = this.props.currentRepoInfo.encrypted; const path = Utils.encodePath(Utils.joinPath(this.props.path, name)); const cacheBuster = new Date().getTime(); + const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase(); + const isGIF = fileExt === 'gif'; + const src = `${siteRoot}repo/${repoID}/raw${path}?t=${cacheBuster}`; + let thumbnail = ''; + if (repoEncrypted || isGIF) { + thumbnail = src; + } else { + thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`; + } return { - 'name': name, + name, + thumbnail, + src, 'url': `${siteRoot}lib/${repoID}/file${path}`, - 'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`, - 'src': `${siteRoot}repo/${repoID}/raw${path}?t=${cacheBuster}`, 'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}?op=download`, }; }; diff --git a/frontend/src/components/dirent-list-view/dirent-list-view.js b/frontend/src/components/dirent-list-view/dirent-list-view.js index 0c9e06fc32..e418abf9fb 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-view.js +++ b/frontend/src/components/dirent-list-view/dirent-list-view.js @@ -184,14 +184,24 @@ class DirentListView extends React.Component { prepareImageItem = (item) => { const name = item.name; const repoID = this.props.repoID; + const repoEncrypted = this.props.currentRepoInfo.encrypted; const path = Utils.encodePath(Utils.joinPath(this.props.path, name)); + const fileExt = name.substr(name.lastIndexOf('.') + 1).toLowerCase(); + const isGIF = fileExt === 'gif'; + const src = `${siteRoot}repo/${repoID}/raw${path}`; + let thumbnail = ''; + if (repoEncrypted || isGIF) { + thumbnail = src; + } else { + thumbnail = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`; + } return { - 'name': name, + name, + thumbnail, + src, 'url': `${siteRoot}lib/${repoID}/file${path}`, - 'thumbnail': `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${path}`, - 'src': `${siteRoot}repo/${repoID}/raw${path}`, - 'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download`, + 'downloadURL': `${fileServerRoot}repos/${repoID}/files${path}/?op=download` }; };