Created
January 22, 2013 10:57
-
-
Save magnetised/4593797 to your computer and use it in GitHub Desktop.
Example of defining image output sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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