Profile avatar photo not appearing new project members select box with relative url installation
Created by: raulcesar
I have a gitlab installation in a relative url (http://mydomain/gitlab) and was having problems with uploaded avatar pictures not showing up. I applied the patch outlined by the pull request #5522 and this solved the problem for most situations. However, in the selection box to choose new members for a project, where the photo should appear on the left just before the user's name, the image still did not appear.
From what I could inspect, the resource is being requested at the root of my web site, so instead of getting the resource at: http://mydomain/**gitlab**/uploads/user/avatar/12/profile.jpeg , it looked in http://mydomain/uploads/user/avatar/12/profile.jpeg
I traced this to the file users_select.js.coffee (in app/assets/javascripts/) and found that on line 4, the avatar is set to "user.avatar.url". To experiment, I prepended gon.relative_url_root to the user.avatar.url property, like so:
userFormatResult = (user) ->
if user.avatar_url
avatar = gon.relative_url_root + user.avatar_url
else if gon.gravatar_enabled
avatar = gon.gravatar_url
avatar = avatar.replace('%{hash}', md5(user.email))
avatar = avatar.replace('%{size}', '24')
else
avatar = gon.relative_url_root + "/assets/no_avatar.png"
It worked, but I have ZERO knowledge of rails (or ruby for that matter) so I don't know if this is the best place to fix the problem. Perhaps the origin of user.avatar.url is the actual problem or something else completely. Anyway, the issue does appear to stand, and to replicate, all one need do is install gitlab ce in a relative URL and upload avatar image file for a user. Then go to the "add new members" for a project and click on the input field and wait for the list to drop down. The user with the uploaded image should present the problem.
Note that the problem ONLY occurs with uploaded images. the "default" avatar works perfectly, and I did not test GRAVATAR images because the server where I run this instance has issues accessing the internet.
Just an update, I noticed this same issue in the "issue assignee" selection box. Fixed it with the same solution altering the file project_users_select.js.coffee