Skip to content
rack middleware for proxying requests to
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Rack middleware for proxying requests to

This mounts routing in your Rack stack so that paths like /lorem/image/400/200 will serve a 400x200 random image from

The middleware is primarily useful because it will cache responses from lorempixel so that after a few page loads, images should load much faster. Without such local caching you will be stuck hammering their server on every page load, and waiting a few seconds for images to fill in.

It is recommended to only load the middleware in development environments.


Add this line to your application's Gemfile:

gem 'lorem-image-ware'

And then execute:

$ bundle

Or install it yourself as:

$ gem install lorem-image-ware


Mount in your app stack like:

use LoremImageWare::Middleware

If you wish to serve off a directory other than the default /lorem, pass the :root option:

use LoremImageWare::Middleware, :root => "/random_images"

There is a small Helpers module you can include for generating lorem image tags for you. For example in Sinatra classical:

helpers LoremImageWare::Helpers

# In a view
lorem_image_tag(:height => 400, :width => 200, :tag => "sports", :class => "some-class")

The helper will add a class of lorem-image to tags for you, as well as populate the dimensions and set inline height and width styling on the image.


Use cache-control and ETag support for browser caching


  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
Something went wrong with that request. Please try again.