Skip to content

Instantly share code, notes, and snippets.

@DylanFM
Created March 19, 2009 04:11
Show Gist options
  • Select an option

  • Save DylanFM/81582 to your computer and use it in GitHub Desktop.

Select an option

Save DylanFM/81582 to your computer and use it in GitHub Desktop.
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