diff --git a/app/models/user.rb b/app/models/user.rb index d0969a0..02b7228 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/settings/_profile.html.erb b/app/views/settings/_profile.html.erb index 40e2eec..910ad1e 100644 --- a/app/views/settings/_profile.html.erb +++ b/app/views/settings/_profile.html.erb @@ -41,7 +41,7 @@
- <%= 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" %>
<% end %>