diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-15 15:36:15 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-08-15 15:36:15 +0000 |
commit | 38e0c237a448c5d59caad9c6bab8461c7a118c09 (patch) | |
tree | 89d839c3866fa970ab997edc23e61f85cb6fcdde /app/controllers/attachments_controller.rb | |
parent | c4239a4fd2f9c91a43a170d19f3f913022428d0b (diff) | |
download | redmine-38e0c237a448c5d59caad9c6bab8461c7a118c09.tar.gz redmine-38e0c237a448c5d59caad9c6bab8461c7a118c09.zip |
Image attachments are now sent inline to be viewed directly in the browser.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@642 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/attachments_controller.rb')
-rw-r--r-- | app/controllers/attachments_controller.rb | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3ddb052dd..0913de529 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -19,18 +19,13 @@ class AttachmentsController < ApplicationController layout 'base' before_filter :find_project, :check_project_privacy - # sends an attachment def download - send_file @attachment.diskfile, :filename => @attachment.filename - rescue - render_404 - end - - # sends an image to be displayed inline - def show - render(:nothing => true, :status => 404) and return unless @attachment.diskfile =~ /\.(jpeg|jpg|gif|png)$/i - send_file @attachment.diskfile, :filename => @attachment.filename, :type => "image/#{$1}", :disposition => 'inline' + # images are sent inline + send_file @attachment.diskfile, :filename => @attachment.filename, + :type => @attachment.content_type, + :disposition => (@attachment.image? ? 'inline' : 'attachment') rescue + # in case the disk file was deleted render_404 end |