From 8af6c2275be7986405e29ea7278de54614c6e39c Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 28 Sep 2015 17:06:13 +0100 Subject: [PATCH] Make it easier to override default avatar urls --- src/controllers/atoms/MemberAvatar.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/controllers/atoms/MemberAvatar.js b/src/controllers/atoms/MemberAvatar.js index 6ad08911b9..5d93f99947 100644 --- a/src/controllers/atoms/MemberAvatar.js +++ b/src/controllers/atoms/MemberAvatar.js @@ -35,7 +35,10 @@ module.exports = { } }, - defaultAvatarUrl: function(member) { + defaultAvatarUrl: function(member, width, height, resizeMethod) { + if (this.skinnedDefaultAvatarUrl) { + return this.skinnedDefaultAvatarUrl(member, width, height, resizeMethod); + } return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAIAAAADnC86AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNrszQENADAIACB9QjNbxSKP4eagAFnTseHFErFYLBaLxWKxWCwWi8Vi8cX4CzAABSwCRWJw31gAAAAASUVORK5CYII="; }, @@ -50,13 +53,23 @@ module.exports = { }, getInitialState: function() { - return { - imageUrl: MatrixClientPeg.get().getAvatarUrlForMember( + var url = MatrixClientPeg.get().getAvatarUrlForMember( + this.props.member, + this.props.width, + this.props.height, + this.props.resizeMethod, + false + ); + if (!url) { + url = this.defaultAvatarUrl( this.props.member, this.props.width, this.props.height, this.props.resizeMethod - ) + ); + } + return { + imageUrl: url }; } };