v0.16.2 Profile image handling improvement
This commit is contained in:
parent
96cb9e7664
commit
b38e2853bb
@ -1,5 +1,5 @@
|
|||||||
# gossamer threads migration-import code
|
# gossamer threads migration-import code
|
||||||
# v0.16.1
|
# v0.16.2
|
||||||
|
|
||||||
require 'mysql2'
|
require 'mysql2'
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
@ -479,9 +479,15 @@ class GossamerForumsImporter < ImportScripts::Base
|
|||||||
resized_upload = upload_attachment(user, resized_temp_file, file['File_Name'], file_url)
|
resized_upload = upload_attachment(user, resized_temp_file, file['File_Name'], file_url)
|
||||||
next if resized_upload.nil?
|
next if resized_upload.nil?
|
||||||
|
|
||||||
# Set the avatar usign the resized image
|
# Ensure the upload ID is valid and exists
|
||||||
user.user_avatar = UserAvatar.create!(user_id: user.id, custom_upload_id: resized_upload.id)
|
if resized_upload && UserAvatar.exists?(custom_upload_id: resized_upload.id)
|
||||||
user.save!
|
# Set the avatar using the resized image
|
||||||
|
user.user_avatar = UserAvatar.create!(user_id: user.id, custom_upload_id: resized_upload.id)
|
||||||
|
user.save!
|
||||||
|
puts "Avatar set for user #{user.username} with upload ID #{resized_upload.id}"
|
||||||
|
else
|
||||||
|
puts "Failed to set avatar for user #{user.username}"
|
||||||
|
end
|
||||||
|
|
||||||
# Set the Profile Header
|
# Set the Profile Header
|
||||||
UserProfile.find_by(user_id: user.id).update!(profile_background_upload_id: upload.id)
|
UserProfile.find_by(user_id: user.id).update!(profile_background_upload_id: upload.id)
|
||||||
|
Loading…
Reference in New Issue
Block a user