mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 00:00:00 +00:00
[thumbnail] added 'thumbnail_size_for_original'
This commit is contained in:
@@ -17,7 +17,8 @@ from constance import config
|
|||||||
from seahub.settings import SEAFILE_VERSION, SITE_TITLE, SITE_NAME, \
|
from seahub.settings import SEAFILE_VERSION, SITE_TITLE, SITE_NAME, \
|
||||||
MAX_FILE_NAME, BRANDING_CSS, LOGO_PATH, LOGO_WIDTH, LOGO_HEIGHT,\
|
MAX_FILE_NAME, BRANDING_CSS, LOGO_PATH, LOGO_WIDTH, LOGO_HEIGHT,\
|
||||||
SHOW_REPO_DOWNLOAD_BUTTON, SITE_ROOT, ENABLE_GUEST_INVITATION, \
|
SHOW_REPO_DOWNLOAD_BUTTON, SITE_ROOT, ENABLE_GUEST_INVITATION, \
|
||||||
FAVICON_PATH, ENABLE_THUMBNAIL, MEDIA_ROOT
|
FAVICON_PATH, ENABLE_THUMBNAIL, THUMBNAIL_SIZE_FOR_ORIGINAL, \
|
||||||
|
MEDIA_ROOT
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from seahub.settings import SEACLOUD_MODE
|
from seahub.settings import SEACLOUD_MODE
|
||||||
@@ -108,6 +109,7 @@ def base(request):
|
|||||||
'constance_enabled': dj_settings.CONSTANCE_ENABLED,
|
'constance_enabled': dj_settings.CONSTANCE_ENABLED,
|
||||||
'FILE_SERVER_ROOT': file_server_root,
|
'FILE_SERVER_ROOT': file_server_root,
|
||||||
'enable_thumbnail': ENABLE_THUMBNAIL,
|
'enable_thumbnail': ENABLE_THUMBNAIL,
|
||||||
|
'thumbnail_size_for_original': THUMBNAIL_SIZE_FOR_ORIGINAL,
|
||||||
'enable_guest_invitation': ENABLE_GUEST_INVITATION,
|
'enable_guest_invitation': ENABLE_GUEST_INVITATION,
|
||||||
'enable_terms_and_conditions': dj_settings.ENABLE_TERMS_AND_CONDITIONS,
|
'enable_terms_and_conditions': dj_settings.ENABLE_TERMS_AND_CONDITIONS,
|
||||||
'is_pro': True if is_pro_version() else False,
|
'is_pro': True if is_pro_version() else False,
|
||||||
|
@@ -519,6 +519,7 @@ THUMBNAIL_EXTENSION = 'png'
|
|||||||
# for thumbnail: height(px) and width(px)
|
# for thumbnail: height(px) and width(px)
|
||||||
THUMBNAIL_DEFAULT_SIZE = 48
|
THUMBNAIL_DEFAULT_SIZE = 48
|
||||||
THUMBNAIL_SIZE_FOR_GRID = 192
|
THUMBNAIL_SIZE_FOR_GRID = 192
|
||||||
|
THUMBNAIL_SIZE_FOR_ORIGINAL = 1024
|
||||||
|
|
||||||
# size(MB) limit for generate thumbnail
|
# size(MB) limit for generate thumbnail
|
||||||
THUMBNAIL_IMAGE_SIZE_LIMIT = 20
|
THUMBNAIL_IMAGE_SIZE_LIMIT = 20
|
||||||
|
@@ -253,6 +253,7 @@ app["pageOptions"] = {
|
|||||||
enable_thumbnail: {% if enable_thumbnail %} true {% else %} false {% endif %},
|
enable_thumbnail: {% if enable_thumbnail %} true {% else %} false {% endif %},
|
||||||
thumbnail_default_size: {{ thumbnail_default_size }},
|
thumbnail_default_size: {{ thumbnail_default_size }},
|
||||||
thumbnail_size_for_grid: {{ thumbnail_size_for_grid }},
|
thumbnail_size_for_grid: {{ thumbnail_size_for_grid }},
|
||||||
|
thumbnail_size_for_original: {{ thumbnail_size_for_original }},
|
||||||
language_code: "{{ LANGUAGE_CODE }}",
|
language_code: "{{ LANGUAGE_CODE }}",
|
||||||
enable_encrypted_library: {% if enable_encrypted_library %} true {% else %} false {% endif %},
|
enable_encrypted_library: {% if enable_encrypted_library %} true {% else %} false {% endif %},
|
||||||
enable_repo_history_setting: {% if enable_repo_history_setting %} true {% else %} false {% endif %},
|
enable_repo_history_setting: {% if enable_repo_history_setting %} true {% else %} false {% endif %},
|
||||||
|
@@ -127,9 +127,9 @@ $('#file-save-form').submit(function() {
|
|||||||
{% if enable_thumbnail %}
|
{% if enable_thumbnail %}
|
||||||
{% if from_shared_dir %}
|
{% if from_shared_dir %}
|
||||||
var encoded_path = encodePath('{{ path|escapejs }}'); // path: '/Portrait_8.jpg'
|
var encoded_path = encodePath('{{ path|escapejs }}'); // path: '/Portrait_8.jpg'
|
||||||
$('#image-view').attr('src', '{{ SITE_ROOT }}thumbnail/{{ shared_token }}/1024' + encoded_path);
|
$('#image-view').attr('src', '{{ SITE_ROOT }}thumbnail/{{ shared_token }}/{{ thumbnail_size_for_original }}' + encoded_path);
|
||||||
{% else %}
|
{% else %}
|
||||||
$('#image-view').attr('src', '{{ SITE_ROOT }}thumbnail/{{ shared_token }}/1024/' + encodeURIComponent('{{file_name|escapejs}}'));
|
$('#image-view').attr('src', '{{ SITE_ROOT }}thumbnail/{{ shared_token }}/{{ thumbnail_size_for_original }}/' + encodeURIComponent('{{file_name|escapejs}}'));
|
||||||
{% endif %}
|
{% endif %}
|
||||||
$('#image-view').on('error', function() { // fail to load thumbnail
|
$('#image-view').on('error', function() { // fail to load thumbnail
|
||||||
$(this).attr('src', '{{ raw_path|escapejs }}');
|
$(this).attr('src', '{{ raw_path|escapejs }}');
|
||||||
|
@@ -27,7 +27,7 @@ body { overflow:hidden; }
|
|||||||
{% if enable_thumbnail and not repo.encrypted %}
|
{% if enable_thumbnail and not repo.encrypted %}
|
||||||
var encoded_path = encodePath('{{ path|escapejs }}'); // path: '/Portrait_8.jpg'
|
var encoded_path = encodePath('{{ path|escapejs }}'); // path: '/Portrait_8.jpg'
|
||||||
$('#image-view')
|
$('#image-view')
|
||||||
.attr('src', '{{ SITE_ROOT }}thumbnail/{{ repo.id }}/1024' + encoded_path)
|
.attr('src', '{{ SITE_ROOT }}thumbnail/{{ repo.id }}/{{ thumbnail_size_for_original }}' + encoded_path)
|
||||||
.on('error', function() { // fail to load thumbnail
|
.on('error', function() { // fail to load thumbnail
|
||||||
$(this).attr('src', '{{ raw_path|escapejs }}');
|
$(this).attr('src', '{{ raw_path|escapejs }}');
|
||||||
})
|
})
|
||||||
|
@@ -191,7 +191,7 @@ var magnificOptions = {
|
|||||||
$('[data-mfp-src]').each(function(index, item) {
|
$('[data-mfp-src]').each(function(index, item) {
|
||||||
var $item = $(item);
|
var $item = $(item);
|
||||||
var file_name = $item.closest('.file-item').attr('data-name');
|
var file_name = $item.closest('.file-item').attr('data-name');
|
||||||
$item.attr('data-mfp-src', '{{ SITE_ROOT }}thumbnail/{{ token }}/1024' + encodePath(cur_path + file_name));
|
$item.attr('data-mfp-src', '{{ SITE_ROOT }}thumbnail/{{ token }}/{{ thumbnail_size_for_original }}' + encodePath(cur_path + file_name));
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
$('.img-name-link').magnificPopup(magnificOptions);
|
$('.img-name-link').magnificPopup(magnificOptions);
|
||||||
|
@@ -238,7 +238,7 @@ define([
|
|||||||
if (use_thumbnail) {
|
if (use_thumbnail) {
|
||||||
item_src = Common.getUrl($.extend(url_options, {
|
item_src = Common.getUrl($.extend(url_options, {
|
||||||
'name': 'thumbnail_get',
|
'name': 'thumbnail_get',
|
||||||
'size': 1024
|
'size': app.pageOptions.thumbnail_size_for_original
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
item_src = Common.getUrl($.extend(url_options, {
|
item_src = Common.getUrl($.extend(url_options, {
|
||||||
|
@@ -37,7 +37,7 @@ define([
|
|||||||
this.$('.img-name-link').attr('data-mfp-src', Common.getUrl({
|
this.$('.img-name-link').attr('data-mfp-src', Common.getUrl({
|
||||||
'name': 'thumbnail_get',
|
'name': 'thumbnail_get',
|
||||||
'repo_id': data.repo_id,
|
'repo_id': data.repo_id,
|
||||||
'size': 1024,
|
'size': app.pageOptions.thumbnail_size_for_original,
|
||||||
'path': data.encoded_path
|
'path': data.encoded_path
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user