Created
March 19, 2009 04:11
-
-
Save DylanFM/81582 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Merb | |
| module GlobalHelpers | |
| # helpers defined here available to all views. | |
| def scaled_image_tag(max_width, img, opts={}) | |
| #I only need this for scaling with a max width | |
| if opts.has_key? :height | |
| h = (opts[:height].to_f*(max_width.to_f/opts[:width].to_f)).round | |
| opts[:height] = h-(h%18) #For 18px baseline. Distorts. | |
| end | |
| opts[:width] = max_width | |
| image_tag(img, opts) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment