diff options
-rw-r--r-- | app/helpers/application_helper.rb | 7 | ||||
-rw-r--r-- | app/helpers/groups_helper.rb | 9 | ||||
-rw-r--r-- | app/helpers/lazy_image_tag_helper.rb | 6 | ||||
-rw-r--r-- | app/models/concerns/avatarable.rb | 14 |
4 files changed, 27 insertions, 9 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8d02d5de5c3..cfdb95e2498 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -41,7 +41,12 @@ module ApplicationHelper end if project.avatar_url - image_tag project.avatar_url, options + if project.private? + options[:use_original_source] = true + image_tag project.avatar_url(use_asset_path: false), options + else + image_tag project.avatar_url, options + end else # generated icon project_identicon(project, options) end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index 82bceddf1f0..091d98a2c94 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -12,7 +12,7 @@ module GroupsHelper group = Group.find_by_full_path(group) end - group.try(:avatar_url) || ActionController::Base.helpers.image_path('no_group_avatar.png') + group.try(:avatar_url, use_asset_path: false) || ActionController::Base.helpers.image_path('no_group_avatar.png') end def group_title(group, name = nil, url = nil) @@ -89,7 +89,12 @@ module GroupsHelper link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do output = if (group.try(:avatar_url) || show_avatar) && !Rails.env.test? - image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15) + if group.private? + puts "GROUP IS PRIVATE : " + group_icon(group) + image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15, use_original_source: true) + else + image_tag(group_icon(group), class: "avatar-tile", width: 15, height: 15) + end else "" end diff --git a/app/helpers/lazy_image_tag_helper.rb b/app/helpers/lazy_image_tag_helper.rb index 2c5619ac41b..aea1fcc7e91 100644 --- a/app/helpers/lazy_image_tag_helper.rb +++ b/app/helpers/lazy_image_tag_helper.rb @@ -9,7 +9,11 @@ module LazyImageTagHelper unless options.delete(:lazy) == false options[:data] ||= {} - options[:data][:src] = path_to_image(source) + unless options.delete(:use_original_source) == true + options[:data][:src] = path_to_image(source) + else + options[:data][:src] = source + end options[:class] ||= "" options[:class] << " lazy" diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb index 8fbfed11bdf..f8c0327e190 100644 --- a/app/models/concerns/avatarable.rb +++ b/app/models/concerns/avatarable.rb @@ -1,7 +1,7 @@ module Avatarable extend ActiveSupport::Concern - def avatar_path(only_path: true) + def avatar_path(only_path: true, use_asset_path: true) return unless self[:avatar].present? # If only_path is true then use the relative path of avatar. @@ -9,10 +9,14 @@ module Avatarable asset_host = ActionController::Base.asset_host gitlab_host = only_path ? gitlab_config.relative_url_root : gitlab_config.url - # If asset_host is set then it is expected that assets are handled by a standalone host. - # That means we do not want to get GitLab's relative_url_root option anymore. - host = asset_host.present? ? asset_host : gitlab_host + if use_asset_path + # If asset_host is set then it is expected that assets are handled by a standalone host. + # That means we do not want to get GitLab's relative_url_root option anymore. + host = asset_host.present? ? asset_host : gitlab_host - [host, avatar.url].join + [host, avatar.url].join + else + avatar.url + end end end |