Placehold

Placehold is a simple gem that generates placeholder images in Rails. I made it because I was tired of having to look up placeholder image sites to remember what the URLS were. Currently the placeholder site used in this gem is placehold.it

Installation

Add this line to your application's Gemfile:

gem 'placehold'

And then execute:

$ bundle

Or install it yourself as:

$ gem install placehold

Usage

To generate a placeholder image, do the following:

Include the Placehold module somewhere in your application/code

include Placehold

Then use the following where you want the placehold image to appear:

<%= placeholder_image width: 300, height: 150, bgcolor: '04acec', fgcolor: 'fff' %>
# => <img src="http://placehold.it/300x150/04acec/fff" alt="Placehold Image">

All the parameters in the above example are optional, and the defaults for width and height are 300 and 150 respectively.

Planned updates

In the future I plan to add some other placeholder sites such as lorempixel.com. Possibly going to add function to save placeholder image to assets folder so as not requesting new one each time you refresh your page (Rails apps).

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request