PixelHolder is a self-hosted image placeholder generator built on top of Sinatra. Using the Flickr API, images are retrieved and cropped to your specified dimensions. The first load may be slow while the file is downloaded off Flickr, but generated images are cached on your harddrive and will be used instead if present.
If you want to integrate PixelHolder directly into your Ruby app, you can use the PixelHolder RubyGem. You can find it on GitHub here.
There is also a basic jQuery implementation available.
- Clone the repository
- Navigate to the folder in the terminal
- Run
bundle install
- Run
ruby app.rb
PixelHolder works with the following URL format
http://localhost:4567/{image type}/{image dimensions}/{optional image settings}
To add an image to your HTML, simply insert the URL in the src
attribute of the img
tag.
e.g.:
<img src="http://localhost:4567/fill/500x500/background_color:ff0000">
PixelHolder currently generates three types of image placeholders: image, solid fill, and gradient fill. The image type is specified in the first segment of the URL.
The image type can by specified by making the value either fill
, gradient
, or flickr
Dimensions can be specified in the second segment of the URL as either {width}x{height}
for rectangular images or {width}
for square images. e.g. 800x300
For a list of options you can use, please refer to the PixelHolder RubyGem documentation.
Image settings are provided as comma separated entries and take a key:value format:
e.g.
background_color:ff0000,text:show_dimensions