Create a gist now

Instantly share code, notes, and snippets.

@thephw /.bashrc
Last active Oct 13, 2015

What would you like to do?
Kittenify-Rails lets you easily swap out your placeholder images in from placehold it with kittens via a view helper. Sexy hotness. And seriously cute.
export KITTENIFY=1
Kittenify-Rails lets you easily swap out your placeholder images in from placehold it with kittens via a view helper. Sexy hotness. And seriously cute.
module ApplicationHelper
def hold_it(width, height, text = "")
text = text.gsub(/\s/, '+')
if ENV["KITTENIFY"].to_i == 1
url = kitten_it(width, height, text)
else
url = placehold_it(width, height, text)
end
image_tag url, size: "#{width}x#{height}"
end
def placehold_it(width, height, text = "")
"http://placehold.it/#{width}x#{height}&text=#{text}+(#{width}x#{height})"
end
def kitten_it(width, height, text = "", grayscale = false)
"http://placekitten.com/#{grayscale ? "g/" : ""}#{width}/#{height}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment