@@ -357,16 +357,15 module ApplicationHelper | |||
|
357 | 357 | attachments = attachments.sort_by(&:created_on).reverse |
|
358 | 358 | text = text.gsub(/!((\<|\=|\>)?(\([^\)]+\))?(\[[^\]]+\])?(\{[^\}]+\})?)(\S+\.(bmp|gif|jpg|jpeg|png))!/i) do |m| |
|
359 | 359 | style = $1 |
|
360 | filename = $6 | |
|
361 | rf = Regexp.new(Regexp.escape(filename), Regexp::IGNORECASE) | |
|
360 | filename = $6.downcase | |
|
362 | 361 | # search for the picture in attachments |
|
363 |
if found = attachments.detect { |att| att.filename = |
|
|
362 | if found = attachments.detect { |att| att.filename.downcase == filename } | |
|
364 | 363 | image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found |
|
365 | 364 | desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1") |
|
366 | 365 | alt = desc.blank? ? nil : "(#{desc})" |
|
367 | 366 | "!#{style}#{image_url}#{alt}!" |
|
368 | 367 | else |
|
369 | "!#{style}#{filename}!" | |
|
368 | m | |
|
370 | 369 | end |
|
371 | 370 | end |
|
372 | 371 | end |
@@ -89,7 +89,9 class ApplicationHelperTest < HelperTestCase | |||
|
89 | 89 | def test_attached_images |
|
90 | 90 | to_test = { |
|
91 | 91 | 'Inline image: !logo.gif!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', |
|
92 | 'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />' | |
|
92 | 'Inline image: !logo.GIF!' => 'Inline image: <img src="/attachments/download/3" title="This is a logo" alt="This is a logo" />', | |
|
93 | 'No match: !ogo.gif!' => 'No match: <img src="ogo.gif" alt="" />', | |
|
94 | 'No match: !ogo.GIF!' => 'No match: <img src="ogo.GIF" alt="" />' | |
|
93 | 95 | } |
|
94 | 96 | attachments = Attachment.find(:all) |
|
95 | 97 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text, :attachments => attachments) } |
General Comments 0
You need to be logged in to leave comments.
Login now