Inline images alt attribute set to the attachment description.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1328 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
c6271d8361
commit
c37abb6415
|
@ -207,8 +207,10 @@ module ApplicationHelper
|
||||||
rf = Regexp.new(filename, Regexp::IGNORECASE)
|
rf = Regexp.new(filename, Regexp::IGNORECASE)
|
||||||
# search for the picture in attachments
|
# search for the picture in attachments
|
||||||
if found = attachments.detect { |att| att.filename =~ rf }
|
if found = attachments.detect { |att| att.filename =~ rf }
|
||||||
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found.id
|
image_url = url_for :only_path => only_path, :controller => 'attachments', :action => 'download', :id => found
|
||||||
"!#{style}#{image_url}!"
|
desc = found.description.to_s.gsub(/^([^\(\)]*).*$/, "\\1")
|
||||||
|
alt = desc.blank? ? nil : "(#{desc})"
|
||||||
|
"!#{style}#{image_url}#{alt}!"
|
||||||
else
|
else
|
||||||
"!#{style}#{filename}!"
|
"!#{style}#{filename}!"
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,5 +34,6 @@ attachments_003:
|
||||||
container_type: WikiPage
|
container_type: WikiPage
|
||||||
filesize: 280
|
filesize: 280
|
||||||
filename: logo.gif
|
filename: logo.gif
|
||||||
|
description: This is a logo
|
||||||
author_id: 2
|
author_id: 2
|
||||||
|
|
|
@ -45,7 +45,8 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
assert_tag :tag => 'h1', :content => /Another page/
|
assert_tag :tag => 'h1', :content => /Another page/
|
||||||
# Included page with an inline image
|
# Included page with an inline image
|
||||||
assert_tag :tag => 'p', :content => /This is 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
|
end
|
||||||
|
|
||||||
def test_show_unexistent_page_without_edit_right
|
def test_show_unexistent_page_without_edit_right
|
||||||
|
|
Loading…
Reference in New Issue