summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-05 18:56:08 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-05 18:56:08 +0000
commitc37abb64151e18461cb739ed4658d912a7c752e8 (patch)
tree18bedea9c05107adcaf4cfc5061a4d734756076b
parentc6271d836168af455fcc9510907fb4fb330f1d62 (diff)
downloadredmine-c37abb64151e18461cb739ed4658d912a7c752e8.tar.gz
redmine-c37abb64151e18461cb739ed4658d912a7c752e8.zip
Inline images alt attribute set to the attachment description.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1328 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/helpers/application_helper.rb6
-rw-r--r--test/fixtures/attachments.yml1
-rw-r--r--test/functional/wiki_controller_test.rb3
3 files changed, 7 insertions, 3 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e30343ff5..eb8cc2795 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -207,8 +207,10 @@ 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 :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found.id
- "!#{style}#{image_url}!"
+ image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
+ desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
+ alt = desc.blank? ? nil : "(#{desc})"
+ "!#{style}#{image_url}#{alt}!"
else
"!#{style}#{filename}!"
end
diff --git a/test/fixtures/attachments.yml b/test/fixtures/attachments.yml
index 509475c97..162d44720 100644
--- a/test/fixtures/attachments.yml
+++ b/test/fixtures/attachments.yml
@@ -34,5 +34,6 @@ attachments_003:
container_type: WikiPage
filesize: 280
filename: logo.gif
+ description: This is a logo
author_id: 2
\ No newline at end of file
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb
index 68e52600f..bf31e6614 100644
--- a/test/functional/wiki_controller_test.rb
+++ b/test/functional/wiki_controller_test.rb
@@ -45,7 +45,8 @@ class WikiControllerTest < Test::Unit::TestCase
assert_tag :tag => 'h1', :content => /Another page/
# Included page with an inline image
assert_tag :tag => 'p', :content => /This is an inline image/
- assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3' }
+ assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
+ :alt => 'This is a logo' }
end
def test_show_unexistent_page_without_edit_right