FIX: crop & optimize user background profile/card images

This commit is contained in:
Régis Hanol
2015-07-15 17:15:43 +02:00
parent 00aaa692ac
commit b0802abae2
9 changed files with 70 additions and 64 deletions
+1 -7
View File
@@ -59,13 +59,7 @@ class UploadsController < ApplicationController
content_type = file.content_type
end
# when we're dealing with an avatar, crop it to its maximum size
if type == "avatar" && FileHelper.is_image?(filename)
max = Discourse.avatar_sizes.max
OptimizedImage.resize(tempfile.path, tempfile.path, max, max, allow_animation: SiteSetting.allow_animated_avatars)
end
upload = Upload.create_for(current_user.id, tempfile, filename, tempfile.size, content_type: content_type)
upload = Upload.create_for(current_user.id, tempfile, filename, tempfile.size, content_type: content_type, image_type: type)
if upload.errors.empty? && current_user.admin?
retain_hours = params[:retain_hours].to_i