Moves attachments parsing after textile parsing so that:
* attachments parsing does not rely on textile syntax * textile output can be cached (#4482) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3253 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a359ffb397
commit
b718d5dec2
|
@ -402,6 +402,8 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
return '' if text.blank?
|
return '' if text.blank?
|
||||||
|
|
||||||
|
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
|
||||||
|
|
||||||
only_path = options.delete(:only_path) == false ? false : true
|
only_path = options.delete(:only_path) == false ? false : true
|
||||||
|
|
||||||
# when using an image link, try to use an attachment, if possible
|
# when using an image link, try to use an attachment, if possible
|
||||||
|
@ -409,22 +411,23 @@ module ApplicationHelper
|
||||||
|
|
||||||
if attachments
|
if attachments
|
||||||
attachments = attachments.sort_by(&:created_on).reverse
|
attachments = attachments.sort_by(&:created_on).reverse
|
||||||
text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
|
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
|
||||||
style = $1
|
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
||||||
filename = $6.downcase
|
|
||||||
# search for the picture in attachments
|
# search for the picture in attachments
|
||||||
if found = attachments.detect { |att| att.filename.downcase == filename }
|
if found = attachments.detect { |att| att.filename.downcase == filename }
|
||||||
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
|
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
|
||||||
desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
|
desc = found.description.to_s.gsub('"', '')
|
||||||
alt = desc.blank? ? nil : "(#{desc})"
|
if !desc.blank? && alttext.blank?
|
||||||
"!#{style}#{image_url}#{alt}!"
|
alt = " title=\"#{desc}\" alt=\"#{desc}\""
|
||||||
|
end
|
||||||
|
"src=\"#{image_url}\"#{alt}"
|
||||||
else
|
else
|
||||||
m
|
m
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
|
|
||||||
|
|
||||||
# different methods for formatting wiki links
|
# different methods for formatting wiki links
|
||||||
case options[:wiki_links]
|
case options[:wiki_links]
|
||||||
|
|
Loading…
Reference in New Issue