Created
November 23, 2011 01:21
-
-
Save victorbstan/1387657 to your computer and use it in GitHub Desktop.
Paperclip Validate minimum image dimensions
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
validate :check_dimensions | |
def check_dimensions | |
temp_file = background_image.queued_for_write[:original] | |
unless temp_file.nil? | |
dimensions = Paperclip::Geometry.from_file(temp_file) | |
width = dimensions.width | |
height = dimensions.height | |
if width < 800 && height < 600 | |
errors[''] << " dimensions are too small. For a good quality background please upload a larger image. Minimum width: 800px, minimum height: 600px" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment