Add user avatars to LDAP, upload on profile settings page #148

Merged
raucao merged 11 commits from feature/123-user_avatars into master 2023-09-13 13:01:25 +00:00
2 changed files with 6 additions and 10 deletions
Showing only changes of commit 64d09cfb7f - Show all commits

View File

@ -9,7 +9,11 @@ class User < ApplicationRecord
# File attachments
#
has_one_attached :avatar
has_one_attached :avatar do |attachable|
attachable.variant :small, resize_to_fill: [64, 64]
attachable.variant :medium, resize_to_fill: [256, 256]
attachable.variant :large, resize_to_fill: [512, 512]
end
#
# Relations
@ -163,14 +167,6 @@ class User < ApplicationRecord
@display_name ||= ldap_entry[:display_name]
end
def avatar_64px
avatar.variant(resize_to_fill: [64, 64])
end
def avatar_256px
avatar.variant(resize_to_fill: [256, 256])
end
def services_enabled
ldap_entry[:service] || []
end

View File

@ -41,7 +41,7 @@
<div class="flex items-center gap-6">
<% if current_user.avatar.attached? %>
<p class="flex-none">
<%= image_tag current_user.reload.avatar_256px, class: "h-24 w-24 rounded-lg" %>
<%= image_tag current_user.reload.avatar.variant(:medium), class: "h-24 w-24 rounded-lg" %>
</p>
<% end %>
<div class="grow">