diff --git a/media/js/base.js b/media/js/base.js
index 55c648503b..a50337da6c 100644
--- a/media/js/base.js
+++ b/media/js/base.js
@@ -657,3 +657,12 @@ function quotaSizeFormat(bytes, precision) {
return bytes + ' B';
}
}
+
+function encodePath(path) {
+ var path_arr = path.split('/'),
+ path_arr_ = [];
+ for (var i = 0, len = path_arr.length; i < len; i++) {
+ path_arr_.push(encodeURIComponent(path_arr[i]));
+ }
+ return path_arr_.join('/');
+}
diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py
index 3df80bced6..8d73390263 100644
--- a/seahub/base/context_processors.py
+++ b/seahub/base/context_processors.py
@@ -16,7 +16,7 @@ from constance import config
from seahub.settings import SEAFILE_VERSION, SITE_TITLE, SITE_NAME, \
MAX_FILE_NAME, BRANDING_CSS, LOGO_PATH, LOGO_WIDTH, LOGO_HEIGHT,\
SHOW_REPO_DOWNLOAD_BUTTON, SITE_ROOT, ENABLE_GUEST_INVITATION, \
- FAVICON_PATH
+ FAVICON_PATH, ENABLE_THUMBNAIL
try:
from seahub.settings import SEACLOUD_MODE
@@ -86,6 +86,7 @@ def base(request):
'SITE_ROOT': SITE_ROOT,
'constance_enabled': dj_settings.CONSTANCE_ENABLED,
'FILE_SERVER_ROOT': file_server_root,
+ 'enable_thumbnail': ENABLE_THUMBNAIL,
'enable_guest_invitation': ENABLE_GUEST_INVITATION,
'enable_terms_and_conditions': dj_settings.ENABLE_TERMS_AND_CONDITIONS,
'is_pro': True if is_pro_version() else False,
diff --git a/seahub/templates/shared_file_view.html b/seahub/templates/shared_file_view.html
index 6f3514d700..b7b1b1602b 100644
--- a/seahub/templates/shared_file_view.html
+++ b/seahub/templates/shared_file_view.html
@@ -122,5 +122,18 @@ $('#file-save-form').submit(function() {
});
{% endif %}
{% include "snippets/file_content_js.html" %}
+
+{% if filetype == 'Image' and not err %}
+ {% if enable_thumbnail %}
+ {% if from_shared_dir %}
+ var encoded_path = encodePath('{{ path|escapejs }}'); // path: '/Portrait_8.jpg'
+ $('#image-view').attr('src', '{{ SITE_ROOT }}thumbnail/{{ shared_token }}/1024' + encoded_path);
+ {% else %}
+ $('#image-view').attr('src', '{{ SITE_ROOT }}thumbnail/{{ shared_token }}/1024/' + encodeURIComponent('{{file_name|escapejs}}'));
+ {% endif %}
+ {% else %}
+ $('#image-view').attr('src', '{{ raw_path|escapejs }}');
+ {% endif %}
+{% endif %}
{% endblock %}
diff --git a/seahub/templates/snippets/file_content_html.html b/seahub/templates/snippets/file_content_html.html
index e323792f7f..66d58ee66a 100644
--- a/seahub/templates/snippets/file_content_html.html
+++ b/seahub/templates/snippets/file_content_html.html
@@ -20,7 +20,7 @@ For details please refer to 'snippets/file_content_js.html'.
{% endif %}
{% if filetype == 'Image' %}
-
+
{% endif %}
{% if filetype == 'Document' or filetype == 'PDF' and not use_pdfjs %}
diff --git a/seahub/templates/snippets/file_content_js.html b/seahub/templates/snippets/file_content_js.html
index 80df860b22..76b70c4ae0 100644
--- a/seahub/templates/snippets/file_content_js.html
+++ b/seahub/templates/snippets/file_content_js.html
@@ -17,11 +17,7 @@
{% endif %}
{% if filetype == 'Image' %}
-function setFileViewAreaHeight() {
- var $fileView = $('#file-view');
- $fileView.outerHeight($(window).height() - $fileView.offset().top);
-}
-$(window).load(setFileViewAreaHeight).resize(setFileViewAreaHeight);
+{% include 'snippets/image_file_view_js.html' %}
{% endif %}
{% if filetype == 'SVG' %}
diff --git a/seahub/templates/snippets/image_file_view_js.html b/seahub/templates/snippets/image_file_view_js.html
new file mode 100644
index 0000000000..599a619051
--- /dev/null
+++ b/seahub/templates/snippets/image_file_view_js.html
@@ -0,0 +1,5 @@
+function setFileViewAreaHeight() {
+ var $fileView = $('#file-view');
+ $fileView.outerHeight($(window).height() - $fileView.offset().top);
+}
+$(window).load(setFileViewAreaHeight).resize(setFileViewAreaHeight);
diff --git a/seahub/templates/view_file_image.html b/seahub/templates/view_file_image.html
index 1c8c757369..da069f334f 100644
--- a/seahub/templates/view_file_image.html
+++ b/seahub/templates/view_file_image.html
@@ -17,12 +17,21 @@ body { overflow:hidden; }
{% endif %}
-
+
{% endblock %}
{% block extra_script %}{{ block.super }}
{% endblock %}
diff --git a/seahub/templates/view_history_file.html b/seahub/templates/view_history_file.html
index 4b15d03213..e43e3b3b67 100644
--- a/seahub/templates/view_history_file.html
+++ b/seahub/templates/view_history_file.html
@@ -36,6 +36,7 @@ $(function() {
{% if filetype == 'PDF' and use_pdfjs and not err %}
{% elif filetype == 'Image' and not err %}
+ $('#image-view').attr('src', '{{ raw_path|escapejs }}');
{% else %}
function setFileViewAreaHeight() {
$('body').css({'overflow':'auto'});
diff --git a/seahub/templates/view_shared_dir.html b/seahub/templates/view_shared_dir.html
index 15880a6ff6..549abd6d37 100644
--- a/seahub/templates/view_shared_dir.html
+++ b/seahub/templates/view_shared_dir.html
@@ -162,6 +162,10 @@
{% block extra_script %}