diff --git a/frontend/src/view-file-image.js b/frontend/src/view-file-image.js
index ed6c2dcf36..86a26ca8f9 100644
--- a/frontend/src/view-file-image.js
+++ b/frontend/src/view-file-image.js
@@ -9,7 +9,7 @@ import './css/image-file-view.css';
const {
repoID, filePath, err,
- fileName, previousImage, nextImage, rawPath
+ fileName, previousImage, nextImage, rawPath, thumbnailSizeForOriginal,
} = window.app.pageOptions;
let previousImageUrl, nextImageUrl;
@@ -30,6 +30,14 @@ class ViewFileImage extends React.Component {
class FileContent extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ thumbnailError: false,
+ };
+ this.thumbnailSuffixList = ['tiff', 'eps', 'psd'];
+ }
+
componentDidMount() {
document.addEventListener('keydown', (e) => {
if (previousImage && e.keyCode == 37) { // press '<-'
@@ -41,10 +49,20 @@ class FileContent extends React.Component {
});
}
+ handleError = () => {
+ this.setState({
+ thumbnailError: true
+ });
+ };
+
render() {
- if (err) {
+ if (err || this.state.thumbnailError) {
return ;
}
+ let thumbnailUrl = `${siteRoot}thumbnail/${repoID}/${thumbnailSizeForOriginal}${Utils.encodePath(filePath)}`;
+ let imageSuffix = fileName.split('.').pop();
+ let isPreviewThumbnail = this.thumbnailSuffixList.includes(imageSuffix);
+
return (
{previousImage && (
@@ -53,7 +71,10 @@ class FileContent extends React.Component {
{nextImage && (
)}
-

+ {isPreviewThumbnail ?
+

:
+

+ }
);
}
diff --git a/seahub/templates/file_view_react.html b/seahub/templates/file_view_react.html
index bb15f0cb75..b661406343 100644
--- a/seahub/templates/file_view_react.html
+++ b/seahub/templates/file_view_react.html
@@ -16,6 +16,7 @@ window.app.pageOptions = {
shareLinkExpireDaysDefault: {{ share_link_expire_days_default }},
shareLinkExpireDaysMin: {{ share_link_expire_days_min }},
shareLinkExpireDaysMax: {{ share_link_expire_days_max }},
+ thumbnailSizeForOriginal: {{ thumbnail_size_for_original }},
// for all types of files
fileName: '{{ filename|escapejs }}',
diff --git a/seahub/views/file.py b/seahub/views/file.py
index 95d58d05e1..5997e24717 100644
--- a/seahub/views/file.py
+++ b/seahub/views/file.py
@@ -531,6 +531,7 @@ def view_lib_file(request, repo_id, path):
'share_link_expire_days_max': SHARE_LINK_EXPIRE_DAYS_MAX,
'can_download_file': parse_repo_perm(permission).can_download,
'seafile_collab_server': SEAFILE_COLLAB_SERVER,
+ 'thumbnail_size_for_original': settings.THUMBNAIL_SIZE_FOR_ORIGINAL,
}
# check whether file is starred