diff --git a/UI/WebServerResources/js/Common/Gravatar.service.js b/UI/WebServerResources/js/Common/Gravatar.service.js index 3c9f37832..f96463374 100644 --- a/UI/WebServerResources/js/Common/Gravatar.service.js +++ b/UI/WebServerResources/js/Common/Gravatar.service.js @@ -8,12 +8,12 @@ * @memberof SOGo.Common * @param {string} email * @param {number} [size] - the size of the image - * @param {string} alternate avatar to use + * @param {string} alternate avatar to use (none, identicon, monsterid, wavatar, retro) * @ngInject */ function Gravatar() { - return function(email, size, alternate_avatar) { - var x, y, hash, s = size; + return function(email, size, alternate_avatar, options) { + var x, y, hash, s = size, a = alternate_avatar; if (!email) { return ''; } @@ -28,8 +28,12 @@ } hash = email.md5(); - if (alternate_avatar == "none") - alternate_avatar = "404"; + if (!a || a == "none") { + if (options && options.no_404) + alternate_avatar = "mm"; // mystery man alternative + else + alternate_avatar = "404"; + } return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=' + alternate_avatar; }; diff --git a/UI/WebServerResources/js/Common/User.service.js b/UI/WebServerResources/js/Common/User.service.js index 3f44e91bd..1bb8d596a 100644 --- a/UI/WebServerResources/js/Common/User.service.js +++ b/UI/WebServerResources/js/Common/User.service.js @@ -110,7 +110,7 @@ if (!this.$$shortFormat) this.$$shortFormat = this.$shortFormat(); if (!this.$$image) - this.$$image = this.image || User.$gravatar(this.c_email, 32, User.$alternateAvatar); + this.$$image = this.image || User.$gravatar(this.c_email, 32, User.$alternateAvatar, {no_404: true}); // An empty attribute to trick md-autocomplete when adding users from the ACLs editor this.empty = ' '; diff --git a/UI/WebServerResources/js/Contacts/Card.service.js b/UI/WebServerResources/js/Contacts/Card.service.js index 52634135b..9f33c8504 100644 --- a/UI/WebServerResources/js/Contacts/Card.service.js +++ b/UI/WebServerResources/js/Contacts/Card.service.js @@ -49,6 +49,8 @@ if (Preferences.defaults.SOGoContactsCategories) { Card.$categories = Preferences.defaults.SOGoContactsCategories; } + if (Preferences.defaults.SOGoAlternateAvatar) + Card.$alternateAvatar = Preferences.defaults.SOGoAlternateAvatar; }); return Card; // return constructor @@ -131,7 +133,7 @@ if (!this.$$email) this.$$email = this.$preferredEmail(partial); if (!this.$$image) - this.$$image = this.image || Card.$gravatar(this.$preferredEmail(partial), 32); + this.$$image = this.image || Card.$gravatar(this.$preferredEmail(partial), 32, Card.$alternateAvatar, {no_404: true}); this.selected = false; // An empty attribute to trick md-autocomplete when adding attendees from the appointment editor