]> source.dussan.org Git - redmine.git/commitdiff
Inline images alt attribute set to the attachment description.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 Apr 2008 18:56:08 +0000 (18:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 5 Apr 2008 18:56:08 +0000 (18:56 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1328 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/application_helper.rb
test/fixtures/attachments.yml
test/functional/wiki_controller_test.rb

index e30343ff54b5da5b30deb3fe845b304d8ed9b273..eb8cc2795b9da265c14d44d821218b5e760d6204 100644 (file)
@@ -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
index 509475c9765f3c812ff5feed3211883f4424a22a..162d44720db2ad4e3c9141e3ab5703dddc272f8c 100644 (file)
@@ -34,5 +34,6 @@ attachments_003:
   container_type: WikiPage\r
   filesize: 280\r
   filename: logo.gif\r
+  description: This is a logo\r
   author_id: 2\r
   
\ No newline at end of file
index 68e52600f2ec5c26b6daa520f0080ab05f4682f6..bf31e66142d28369f13364a3e9cffd5b085cdd3c 100644 (file)
@@ -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