Created
May 6, 2011 07:49
-
-
Save patsanch/958576 to your computer and use it in GitHub Desktop.
Paperclip Rotator
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
module Paperclip | |
class Rotator < Thumbnail | |
def transformation_command | |
if rotate_command | |
# having the "super" at the end ensures that your thumbnails are allways "inside the limits of your styles" | |
# for some reason, super returns: ["-resize", "\"300x300>\""]:Array | |
"#{rotate_command} #{super.join(' ')}" | |
else | |
super | |
end | |
end | |
def rotate_command | |
target = @attachment.instance | |
if target.rotating? | |
" -rotate #{target.rotation}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment