diff -urN redmine.orig/app/helpers/application_helper.rb redmine/app/helpers/application_helper.rb --- redmine.orig/app/helpers/application_helper.rb 2010-10-12 10:14:56.385054626 +0300 +++ redmine/app/helpers/application_helper.rb 2010-10-12 18:22:09.322462057 +0300 @@ -509,17 +509,23 @@ # when using an image link, try to use an attachment, if possible if options[:attachments] || (obj && obj.respond_to?(:attachments)) attachments = nil - text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| - filename, ext, alt, alttext = $1.downcase, $2, $3, $4 - attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse - # search for the picture in attachments + text.gsub!(/((]+src\s*=\s*)|(]+href\s*=\s*))(("[^"]+")|('[^']+'))(\s+alt="([^"]*)")?/i) do |m| + prefix = $1 + filename = $4.downcase.gsub(/^["'](.+)["']$/, '\1') + alt, alttext = $5, $6 + attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse + # search for the file in attachments if found = attachments.detect { |att| att.filename.downcase == filename } - image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found + file_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found desc = found.description.to_s.gsub('"', '') if !desc.blank? && alttext.blank? alt = " title=\"#{desc}\" alt=\"#{desc}\"" end - "src=\"#{image_url}\"#{alt}" + if prefix =~ /^