diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 24186adef..a9b7cce84 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -182,7 +182,7 @@ module ApplicationHelper else raw("") + " ref='#{'missing-img' unless user.avatar.attached?}'>") end html = @@ -200,22 +200,14 @@ module ApplicationHelper # No more dirty hack def user_avatar_absolute_url(user, style) - begin - unless missing_avatar(user, style) - image = File.open(user.avatar_variant(style)) - encoded_data = Base64.strict_encode64(image) - avatar_base64 = "data:#{user.avatar_content_type};base64,#{encoded_data}" - return avatar_base64 - end - rescue StandardError => e - Rails.logger.error e.message + avatar_link = user.avatar_variant(style) + if user.avatar.attached? + avatar_link.processed.service_url(expires_in: Constants::URL_LONG_EXPIRE_TIME) + else + avatar_link end - url_for("/images/#{style}/missing.png") - end - - def missing_avatar(user, style) - user.avatar == '/images/icon_small/missing.png' || - user.avatar == '/images/thumb/missing.png' + rescue StandardError => e + Rails.logger.error e.message end def wopi_enabled? diff --git a/app/models/user.rb b/app/models/user.rb index 8087b5c84..0ca3b4687 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -249,7 +249,7 @@ class User < ApplicationRecord end def avatar_variant(style) - return Constants::DEFAULT_AVATAR_URL.gsub(':style', style) unless avatar.attached? + return Constants::DEFAULT_AVATAR_URL.gsub(':style', style.to_s) unless avatar.attached? format = case style.to_sym when :medium diff --git a/app/views/shared/comments/_item.html.erb b/app/views/shared/comments/_item.html.erb index 2b7b49edc..305645882 100644 --- a/app/views/shared/comments/_item.html.erb +++ b/app/views/shared/comments/_item.html.erb @@ -14,7 +14,7 @@