##// END OF EJS Templates
Moves attachments parsing after textile parsing so that:...
Jean-Philippe Lang -
r3139:b718d5dec207
parent child
Show More
@@ -402,6 +402,8 module ApplicationHelper
402 402 end
403 403 return '' if text.blank?
404 404
405 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
406
405 407 only_path = options.delete(:only_path) == false ? false : true
406 408
407 409 # when using an image link, try to use an attachment, if possible
@@ -409,22 +411,23 module ApplicationHelper
409 411
410 412 if attachments
411 413 attachments = attachments.sort_by(&:created_on).reverse
412 text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m|
413 style = $1
414 filename = $6.downcase
414 text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
415 filename, ext, alt, alttext = $1.downcase, $2, $3, $4
416
415 417 # search for the picture in attachments
416 418 if found = attachments.detect { |att| att.filename.downcase == filename }
417 419 image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
418 desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
419 alt = desc.blank? ? nil : "(#{desc})"
420 "!#{style}#{image_url}#{alt}!"
420 desc = found.description.to_s.gsub('"', '')
421 if !desc.blank? && alttext.blank?
422 alt = " title=\"#{desc}\" alt=\"#{desc}\""
423 end
424 "src=\"#{image_url}\"#{alt}"
421 425 else
422 426 m
423 427 end
424 428 end
425 429 end
426 430
427 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text) { |macro, args| exec_macro(macro, obj, args) }
428 431
429 432 # different methods for formatting wiki links
430 433 case options[:wiki_links]
General Comments 0
You need to be logged in to leave comments. Login now