Restrict paperclip for fixed dimensions
How can restrict/ validat开发者_运维技巧e paperclip for uploading image with fixed dimentions.
I want to upload image with a fixed dimensions else it should show an error displaying that the size is not proper and upload it with fixed size
To get the size of the image, you can do in your model:
def image_valid?
g = Paperclip::Geometry.from_file(photo.to_file(:original))
g.width < 500 && g.height < 700 #change these numbers
(Assuming you have a has_attached_file :photo
in your model).
精彩评论