Skip to content

Instantly share code, notes, and snippets.

@victorbstan
Created November 23, 2011 01:21
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorbstan/1387657 to your computer and use it in GitHub Desktop.
Save victorbstan/1387657 to your computer and use it in GitHub Desktop.
Paperclip Validate minimum image dimensions
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