Last active
October 13, 2015 18:28
-
-
Save thephw/4237725 to your computer and use it in GitHub Desktop.
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.
This file contains 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
export KITTENIFY=1 |
This file contains 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
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. |
This file contains 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 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