From 2b9bce88e12c1e23320a6e4733198d1125939c0d Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Tue, 25 Sep 2012 18:20:13 +0500 Subject: 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. --- actionpack/lib/action_view/helpers/asset_tag_helper.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_view') 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 # # * :alt - If no alt text is given, the file name part of the # +source+ is used (capitalized and without the extension) - # * :size - Supplied as "{Width}x{Height}", so "30x45" becomes - # width="30" and height="45". :size will be ignored if the - # value is not in the correct format. + # * :size - Supplied as "{Width}x{Height}" or "{Number}", so "30x45" becomes + # width="30" and height="45", and "50" becomes width="50" and height="50". + # :size will be ignored if the value is not in the correct format. # # image_tag("icon") # # => Icon @@ -374,7 +374,7 @@ module ActionView # # => Icon # image_tag("icon.png", :size => "16x10", :alt => "Edit Entry") # # => Edit Entry - # image_tag("/icons/icon.gif", :size => "16x16") + # image_tag("/icons/icon.gif", :size => "16") # # => Icon # image_tag("/icons/icon.gif", :height => '32', :width => '32') # # => Icon @@ -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) -- cgit v1.2.3