Skip to content

Instantly share code, notes, and snippets.

@telekineticyeti
Created August 13, 2013 01:56
Show Gist options
  • Select an option

  • Save telekineticyeti/6217148 to your computer and use it in GitHub Desktop.

Select an option

Save telekineticyeti/6217148 to your computer and use it in GitHub Desktop.
A simple ruby method that was created as a Middleman (http://middlemanapp.com/) helper. It generates an img tag, using stock images from lorempixel (formerly lorempixum).
# lorempixel
# Outputs a (random) image of specified dimensions
# from http://lorempixel.com/.
# Example: =lorempixel "300x150"
#
# Use :theme => 'category'
# to set a specific theme
def lorempixel(dimensions, opt = {})
sizeXY = dimensions.split("x")
themes = [ 'abstract','animals','business','cats','city','food','nightlife','fashion','people','nature','sports','technics','transport' ]
opt[:theme] ||= themes.sample
'<img src="http://lorempixel.com/'+sizeXY[0]+'/'+sizeXY[1]+'/'+opt[:theme]+'">'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment