Created
April 2, 2011 17:18
-
-
Save andrellima/899674 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 GalleryPhoto < ActiveRecord::Base | |
belongs_to :gallery | |
has_attached_file :photo, | |
:styles => { :small => ["150", :png], :large => ["500", :png], :very_large => ['750x500>', :png] }, | |
:path => ":rails_root/public/images/:class/:attachment/:id/:style_:basename.png", | |
:url => "/images/:class/:attachment/:id/:style_:basename.png", | |
:default_url => "/images/sem_imagem.gif" | |
def geometry | |
geo = Paperclip::Geometry.from_file(photo.to_file(:large)) | |
ratio = geo.width/geo.height | |
if ratio > 1 | |
return 'horizontal' | |
else | |
return 'vertical' | |
end | |
end | |
def width | |
geo = Paperclip::Geometry.from_file(photo.to_file(:large)) | |
return geo.width | |
end | |
def height | |
geo = Paperclip::Geometry.from_file(photo.to_file(:large)) | |
return geo.height | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment