Module: PlaceholdIt::Common
- Included in:
- ControllerExtensions, ViewExtensions
- Defined in:
- lib/placehold_it/common.rb
Instance Method Summary collapse
-
#placeholder_image_url(size = "200x150", *args) ⇒ Object
Source: gist.github.com/473254 Thanks very much to Zeke Sikelianos (github.com/zeke).
Instance Method Details
#placeholder_image_url(size = "200x150", *args) ⇒ Object
Source: gist.github.com/473254 Thanks very much to Zeke Sikelianos (github.com/zeke)
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/placehold_it/common.rb', line 7 def placeholder_image_url(size="200x150", *args) = args. # If fg is present, bg is required (and vice versa) [:bg] = "FFF" if [:fg].present? && [:bg].blank? [:fg] = "000" if [:bg].present? && [:fg].blank? parts = [] parts << "http://placehold.it" parts << "/#{size}" parts << "/#{[:bg]}" if [:bg].present? parts << "/#{[:fg]}" if [:fg].present? parts << "&text=#{[:text]}" if [:text].present? parts.join "" end |