diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 3ddb052dd8d563f09b5a610eaea18f2295e0a884..0913de529e64f14a1be42ebe87beb50a5d898953 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
  
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index cdf69d76cf9c93f853f43d3701bfb375fff8e70f..f4d8a0d547343bda5ae5dfd92a096d6fb742e5ce 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -163,7 +163,7 @@ module ApplicationHelper
         rf = Regexp.new(filename,  Regexp::IGNORECASE)
         # search for the picture in attachments
         if found = attachments.detect { |att| att.filename =~ rf }
-          image_url = url_for :controller => 'attachments', :action => 'show', :id => found.id
+          image_url = url_for :controller => 'attachments', :action => 'download', :id => found.id
           "!#{align}#{image_url}!"
         else
           "!#{align}#{filename}!"
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 108baf99ad791890be33c3cc5bcee2932a813fce..443a75babbc0e5028a071636cd6977cabe09ced4 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -84,6 +84,10 @@ class Attachment < ActiveRecord::Base
     container.is_a?(Project) ? container : container.project
   end
   
+  def image?
+    self.filename =~ /\.(jpeg|jpg|gif|png)$/i
+  end
+  
 private
   def sanitize_filename(value)
       # get only the filename, not the whole path