diff options
author | Johann Pardanaud <pardanaud.j@gmail.com> | 2016-02-09 00:35:42 +0100 |
---|---|---|
committer | Johann Pardanaud <pardanaud.j@gmail.com> | 2016-02-09 22:26:50 +0100 |
commit | 6d5808801f460ed2c7bb99a316687202f2f70282 (patch) | |
tree | 379598f0aeae10b2dce417e4f166e35cff349abb /app/uploaders | |
parent | 16abacb1f07c866e7a1f5deb6a6bc20a4eaee71c (diff) | |
download | gitlab-ce-6d5808801f460ed2c7bb99a316687202f2f70282.tar.gz |
Fix #7959: Fix avatar stretching by providing a cropping feature
Diffstat (limited to 'app/uploaders')
-rw-r--r-- | app/uploaders/avatar_uploader.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/uploaders/avatar_uploader.rb b/app/uploaders/avatar_uploader.rb index 6135c3ad96f..ec9e285b266 100644 --- a/app/uploaders/avatar_uploader.rb +++ b/app/uploaders/avatar_uploader.rb @@ -2,11 +2,20 @@ class AvatarUploader < CarrierWave::Uploader::Base include UploaderHelper + include CarrierWave::MiniMagick storage :file after :store, :reset_events_cache + process :cropper + + def cropper + manipulate! do |img| + img.crop "#{model.avatar_crop_size}x#{model.avatar_crop_size}+#{model.avatar_crop_x}+#{model.avatar_crop_y}" + end + end + def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end |