diff options
Diffstat (limited to 'app/models/profile_photo.rb')
-rw-r--r-- | app/models/profile_photo.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 108e34110..041b5aa57 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -24,6 +24,8 @@ class ProfilePhoto < ActiveRecord::Base WIDTH = 96 HEIGHT = 96 + MAX_DRAFT = 500 # keep even pre-cropped images reasonably small + belongs_to :user # deliberately don't strip_attributes, so keeps raw photo properly @@ -69,6 +71,10 @@ class ProfilePhoto < ActiveRecord::Base image.resize_to_fill!(WIDTH, HEIGHT) altered = true end + if self.draft && (image.columns > MAX_DRAFT || image.rows > MAX_DRAFT) + image.resize_to_fit!(MAX_DRAFT, MAX_DRAFT) + altered = true + end if altered write_attribute(:data, self.image.to_blob) end |