mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-11 00:41:41 +08:00
Fix large preview for documents [SCI-3938]
This commit is contained in:
parent
6a6a43f5ff
commit
dd7f2fe095
2 changed files with 5 additions and 3 deletions
|
|
@ -474,7 +474,7 @@ var FilePreviewModal = (function() {
|
||||||
link.attr('href', downloadUrl);
|
link.attr('href', downloadUrl);
|
||||||
link.attr('data-no-turbolink', true);
|
link.attr('data-no-turbolink', true);
|
||||||
link.attr('data-status', 'asset-present');
|
link.attr('data-status', 'asset-present');
|
||||||
if (data.type === 'image') {
|
if (data.type === 'previewable') {
|
||||||
animateSpinner('.file-preview-container', false);
|
animateSpinner('.file-preview-container', false);
|
||||||
modal.find('.file-preview-container')
|
modal.find('.file-preview-container')
|
||||||
.append($('<img>')
|
.append($('<img>')
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,11 @@ class AssetsController < ApplicationController
|
||||||
before_action :check_edit_permission, only: :edit
|
before_action :check_edit_permission, only: :edit
|
||||||
|
|
||||||
def file_preview
|
def file_preview
|
||||||
|
file_type = 'previewable' if @asset.previewable?
|
||||||
|
file_type ||= @asset.file.metadata[:asset_type]
|
||||||
response_json = {
|
response_json = {
|
||||||
'id' => @asset.id,
|
'id' => @asset.id,
|
||||||
'type' => @asset.file.metadata[:asset_type] || (@asset.image? ? 'image' : 'file'),
|
'type' => file_type,
|
||||||
'filename' => truncate(escape_input(@asset.file_name),
|
'filename' => truncate(escape_input(@asset.file_name),
|
||||||
length: Constants::FILENAME_TRUNCATION_LENGTH),
|
length: Constants::FILENAME_TRUNCATION_LENGTH),
|
||||||
'download-url' => asset_file_url_path(@asset)
|
'download-url' => asset_file_url_path(@asset)
|
||||||
|
|
@ -33,7 +35,7 @@ class AssetsController < ApplicationController
|
||||||
elsif @assoc.class == RepositoryCell
|
elsif @assoc.class == RepositoryCell
|
||||||
can_manage_repository_rows?(@repository)
|
can_manage_repository_rows?(@repository)
|
||||||
end
|
end
|
||||||
if response_json['type'] == 'image'
|
if response_json['type'] == 'previewable'
|
||||||
if ['image/jpeg', 'image/pjpeg'].include? @asset.file.content_type
|
if ['image/jpeg', 'image/pjpeg'].include? @asset.file.content_type
|
||||||
response_json['quality'] = @asset.file_image_quality || 90
|
response_json['quality'] = @asset.file_image_quality || 90
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue