diff --git a/lib/client.js b/lib/client.js index 63fc27959..44365c500 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1393,17 +1393,21 @@ MatrixClient.prototype.setAvatarUrl = function(url, callback) { * @param {Number} height The desired height of the thumbnail. * @param {string} resizeMethod The thumbnail resize method to use, either * "crop" or "scale". + * @param {Boolean} allowDefault (optional) Passing false causes this method to + * return null if the user has no avatar image. Otherwise, a default image URL + * will be returned. * @return {?string} the avatar URL or null. */ MatrixClient.prototype.getAvatarUrlForMember = - function(member, width, height, resizeMethod) { + function(member, width, height, resizeMethod, allowDefault) { if (!member || !member.events.member) { return null; } + if (allowDefault === undefined) { allowDefault = true; } var rawUrl = member.events.member.getContent().avatar_url; if (rawUrl) { return this._http.getHttpUriForMxc(rawUrl, width, height, resizeMethod); - } else { + } else if (allowDefault) { return this._http.getIdenticonUri(member.userId, width, height); } return null;