Skip to content

Instantly share code, notes, and snippets.

@kylemacey
Created April 1, 2013 18:57
Show Gist options
  • Save kylemacey/5286882 to your computer and use it in GitHub Desktop.
Save kylemacey/5286882 to your computer and use it in GitHub Desktop.
Paperclip interpolator to use http://www.placehold.it for default image
Paperclip.interpolates(:placehold_it) do |attachment, style|
# assumes using dimensions specified as integer, eg "250x250#"
params = attachment.styles[style][:geometry].match(/\d+x\d+/).to_s + "&text=#{attachment.instance.name}"
"http://www.placehold.it/" + params
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment