From 1218ead3555c8c1d6290aa98ec31f9b7cc79a03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 29 Nov 2017 12:04:35 +0100 Subject: [PATCH] UX: preloaded gravatar was appearing on the right instead of the left --- .../discourse/helpers/bound-avatar-template.js.es6 | 8 +++++++- app/controllers/user_avatars_controller.rb | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/helpers/bound-avatar-template.js.es6 b/app/assets/javascripts/discourse/helpers/bound-avatar-template.js.es6 index 5682cd2fbdc..e62cf984052 100644 --- a/app/assets/javascripts/discourse/helpers/bound-avatar-template.js.es6 +++ b/app/assets/javascripts/discourse/helpers/bound-avatar-template.js.es6 @@ -1,4 +1,10 @@ import { htmlHelper } from 'discourse-common/lib/helpers'; import { avatarImg } from 'discourse/lib/utilities'; -export default htmlHelper((avatarTemplate, size) => avatarImg({ size, avatarTemplate })); +export default htmlHelper((avatarTemplate, size) => { + if (Ember.isEmpty(avatarTemplate)) { + return "
"; + } else { + return avatarImg({ size, avatarTemplate }); + } +}); diff --git a/app/controllers/user_avatars_controller.rb b/app/controllers/user_avatars_controller.rb index ae93f484310..28d7f8c2d15 100644 --- a/app/controllers/user_avatars_controller.rb +++ b/app/controllers/user_avatars_controller.rb @@ -87,7 +87,7 @@ class UserAvatarsController < ApplicationController return render_blank if version != OptimizedImage::VERSION upload_id = upload_id.to_i - return render_blank unless upload_id > 0 && user_avatar = user.user_avatar + return render_blank unless upload_id > 0 size = params[:size].to_i return render_blank if size < 8 || size > 1000 @@ -98,7 +98,7 @@ class UserAvatarsController < ApplicationController return redirect_to cdn_path(avatar_url) end - upload = Upload.find_by(id: upload_id) if user_avatar.contains_upload?(upload_id) + upload = Upload.find_by(id: upload_id) if user.user_avatar.contains_upload?(upload_id) upload ||= user.uploaded_avatar if user.uploaded_avatar_id == upload_id if user.uploaded_avatar && !upload