diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 045a3d3f3..37da2903d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -233,11 +233,25 @@ module ApplicationHelper raw(user_description) + raw('" >') + user_name + raw('</a>') end + # Dirty, dirty hack for displaying images in reports def user_avatar_absolute_url(user, style) - unless user.avatar(style) == '/images/icon_small/missing.png' - return user.avatar(style) + prefix = '' + if ENV['PAPERCLIP_STORAGE'].present? && + ENV['MAIL_SERVER_URL'].present? && + ENV['PAPERCLIP_STORAGE'] != 'filesystem' + prefix = ENV['MAIL_SERVER_URL'] end - URI.join(Rails.application.routes.url_helpers.root_url, - "/images/#{style}/missing.png").to_s + # for development + prefix = 'localhost:3000' if ENV['MAIL_SERVER_URL'] == 'localhost' + if !prefix.empty? && + !prefix.include?('http://') && + !prefix.include?('https://') + prefix = request.ssl? ? "https://#{prefix}" : "http://#{prefix}" + end + + unless user.avatar(style) == '/images/icon_small/missing.png' + return user.avatar(style, timeout: Constants::URL_LONG_EXPIRE_TIME) + end + url_for(prefix + "/images/#{style}/missing.png") end end