diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-25 09:55:43 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-09-25 09:55:43 -0700 |
commit | 9fec0c8d3522c6b027dbe2df70c49953b2d9bbaa (patch) | |
tree | ffd905956e95ea62d118ea0915bed0bcbce828d9 /actionpack/lib | |
parent | c96b20f8d985c6fa87a8efda7a4884e3c35e5739 (diff) | |
parent | 3164b0a2c1e6b000d933263716f2e3f2ff1cca52 (diff) | |
download | rails-9fec0c8d3522c6b027dbe2df70c49953b2d9bbaa.tar.gz rails-9fec0c8d3522c6b027dbe2df70c49953b2d9bbaa.tar.bz2 rails-9fec0c8d3522c6b027dbe2df70c49953b2d9bbaa.zip |
Merge pull request #7754 from NARKOZ/image_tag-size
Feature: set the same width and height for image if size attribute is a number
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 11 |
1 files changed, 6 insertions, 5 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..27ba57ff58 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" /> @@ -390,7 +390,8 @@ module ActionView end if size = options.delete(:size) - options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$} + options[:width], options[:height] = size.split("x") if size =~ %r{\A\d+x\d+\z} + options[:width] = options[:height] = size if size =~ %r{\A\d+\z} end tag("img", options) |