aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authorNihad Abbasov <narkoz.2008@gmail.com>2012-09-25 18:20:13 +0500
committerNihad Abbasov <narkoz.2008@gmail.com>2012-09-25 21:47:55 +0500
commit2b9bce88e12c1e23320a6e4733198d1125939c0d (patch)
tree7b883c6142528a5eecfd6d16525a5ff4a9afed4e /actionpack/lib/action_view
parentc96b20f8d985c6fa87a8efda7a4884e3c35e5739 (diff)
downloadrails-2b9bce88e12c1e23320a6e4733198d1125939c0d.tar.gz
rails-2b9bce88e12c1e23320a6e4733198d1125939c0d.tar.bz2
rails-2b9bce88e12c1e23320a6e4733198d1125939c0d.zip
allow to pass numerical value to size option in image_tag
This will set image's both width and height attributes to value passed in size option.
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index db4da6f9c8..08efc98a50 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -364,9 +364,9 @@ module ActionView
#
# * <tt>:alt</tt> - If no alt text is given, the file name part of the
# +source+ is used (capitalized and without the extension)
- # * <tt>:size</tt> - Supplied as "{Width}x{Height}", so "30x45" becomes
- # width="30" and height="45". <tt>:size</tt> will be ignored if the
- # value is not in the correct format.
+ # * <tt>:size</tt> - Supplied as "{Width}x{Height}" or "{Number}", so "30x45" becomes
+ # width="30" and height="45", and "50" becomes width="50" and height="50".
+ # <tt>:size</tt> will be ignored if the value is not in the correct format.
#
# image_tag("icon")
# # => <img src="/assets/icon" alt="Icon" />
@@ -374,7 +374,7 @@ module ActionView
# # => <img src="/assets/icon.png" alt="Icon" />
# image_tag("icon.png", :size => "16x10", :alt => "Edit Entry")
# # => <img src="/assets/icon.png" width="16" height="10" alt="Edit Entry" />
- # image_tag("/icons/icon.gif", :size => "16x16")
+ # image_tag("/icons/icon.gif", :size => "16")
# # => <img src="/icons/icon.gif" width="16" height="16" alt="Icon" />
# image_tag("/icons/icon.gif", :height => '32', :width => '32')
# # => <img alt="Icon" height="32" src="/icons/icon.gif" width="32" />
@@ -391,6 +391,7 @@ module ActionView
if size = options.delete(:size)
options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
+ options[:width] = options[:height] = size if size =~ %r{\A\d+\z}
end
tag("img", options)