FEATURE: Allow a user to upload an image for their expansion background.
This commit is contained in:
@@ -461,6 +461,8 @@ class UsersController < ApplicationController
|
||||
upload_avatar_for(user, upload)
|
||||
when "profile_background"
|
||||
upload_profile_background_for(user.user_profile, upload)
|
||||
when "expansion_background"
|
||||
upload_expansion_background_for(user.user_profile, upload)
|
||||
end
|
||||
else
|
||||
render status: 422, text: upload.errors.full_messages
|
||||
@@ -490,6 +492,8 @@ class UsersController < ApplicationController
|
||||
image_type = params.require(:image_type)
|
||||
if image_type == 'profile_background'
|
||||
user.user_profile.clear_profile_background
|
||||
elsif image_type == 'expansion_background'
|
||||
user.user_profile.clear_expansion_background
|
||||
else
|
||||
raise Discourse::InvalidParameters.new(:image_type)
|
||||
end
|
||||
@@ -547,8 +551,11 @@ class UsersController < ApplicationController
|
||||
|
||||
def upload_profile_background_for(user_profile, upload)
|
||||
user_profile.upload_profile_background(upload)
|
||||
# TODO: add a resize job here
|
||||
render json: { url: upload.url, width: upload.width, height: upload.height }
|
||||
end
|
||||
|
||||
def upload_expansion_background_for(user_profile, upload)
|
||||
user_profile.upload_expansion_background(upload)
|
||||
render json: { url: upload.url, width: upload.width, height: upload.height }
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user