Skip to content

Instantly share code, notes, and snippets.

@joshuaclayton
Created July 18, 2010 03:36
Show Gist options
  • Save joshuaclayton/480090 to your computer and use it in GitHub Desktop.
Save joshuaclayton/480090 to your computer and use it in GitHub Desktop.
module ApplicationHelper
def placeholdit(geometry, options = {})
base = "http://placehold.it/"
additional_options = []
if geometry =~ /\A\d+(x\d+)?\z/
additional_options << geometry
else
additional_options << 200
end
additional_options << options[:bg]
additional_options << options[:fg]
base << additional_options.compact.join("/")
if (text = options[:text]).present?
text.gsub!(/&|#/, "")
base += "&text=#{CGI.escape(text)}"
end
image_tag base
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment