Skip to content

Instantly share code, notes, and snippets.

@magnetised
Created January 22, 2013 10:57
Show Gist options
  • Save magnetised/4593797 to your computer and use it in GitHub Desktop.
Save magnetised/4593797 to your computer and use it in GitHub Desktop.
Example of defining image output sizes
class Photo < Piece
field :image do
# Define a list of outputs that will be generated for each image
size :large do
# Here you have access to a minimagick context which can be used to
# apply any ImageMagick process to your uploaded image.
# https://github.com/minimagick/minimagick
fit 640, 360
end
size :black_white do
fit 640, 360
greyscale
end
size :thumbnail do
crop 100, 56
end
end
end
# To use these images within your templates you simply suffix the field name with the size:
#
# ${ image.black_white }
# => <img src="/media/00045/00345/image.black_white.jpg" alt="" />
#
# background-image: url(${ image.thumbnail.src }); width: ${ image.thumbnail.width }px;
# => background-image: url(/media/00045/00345/image.thumbnail.jpg); width: 100px;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment