Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Uses a single avatar URL, allows to override gravatar with a custom URL for avatars in interface_config.js.

Boris Grozeva2c41392dd1b
diff --git a/interface_config.js b/interface_config.js
index 3078707e0d..413640dda0 100644
--- a/interface_config.js
+++ b/interface_config.js
@@ -27,5 +27,7 @@ var interfaceConfig = {
/**
* Whether to only show the filmstrip (and hide the toolbar).
*/
- filmStripOnly: false
+ filmStripOnly: false,
+ RANDOM_AVATAR_URL_PREFIX: false,
+ RANDOM_AVATAR_URL_SUFFIX: false
};
diff --git a/modules/UI/UI.js b/modules/UI/UI.js
index 59070a3db9..9b8ae0ce3a 100644
--- a/modules/UI/UI.js
+++ b/modules/UI/UI.js
@@ -896,11 +896,11 @@ UI.setVideoMuteButtonsState = function (mute) {
}
};
-UI.userAvatarChanged = function (resourceJid, thumbUrl, contactListUrl) {
- VideoLayout.userAvatarChanged(resourceJid, thumbUrl);
- ContactList.userAvatarChanged(resourceJid, contactListUrl);
+UI.userAvatarChanged = function (resourceJid, avatarUrl) {
+ VideoLayout.userAvatarChanged(resourceJid, avatarUrl);
+ ContactList.userAvatarChanged(resourceJid, avatarUrl);
if(resourceJid === APP.xmpp.myResource())
- SettingsMenu.changeAvatar(thumbUrl);
+ SettingsMenu.changeAvatar(avatarUrl);
};
UI.setVideoMute = setVideoMute;
diff --git a/modules/UI/avatar/Avatar.js b/modules/UI/avatar/Avatar.js
index 4a31d7582a..d785bffdd6 100644
--- a/modules/UI/avatar/Avatar.js
+++ b/modules/UI/avatar/Avatar.js
@@ -1,4 +1,4 @@
-/* global Strophe, APP, MD5, config */
+/* global Strophe, APP, MD5, config, interfaceConfig */
var Settings = require("../../settings/Settings");
var users = {};
@@ -18,55 +18,51 @@ var Avatar = {
}
users[jid] = id;
}
- var thumbUrl = this.getThumbUrl(jid);
- var contactListUrl = this.getContactListUrl(jid);
+ var avatarUrl = this.getAvatarUrl(jid);
var resourceJid = Strophe.getResourceFromJid(jid);
- APP.UI.userAvatarChanged(resourceJid, thumbUrl, contactListUrl);
+ APP.UI.userAvatarChanged(resourceJid, avatarUrl);
},
/**
- * Returns image URL for the avatar to be displayed on large video area
- * where current active speaker is presented.
+ * Returns the URL of the image for the avatar of a particular user,
+ * identified by its jid
+ * @param jid
* @param jid full MUC jid of the user for whom we want to obtain avatar URL
*/
- getActiveSpeakerUrl: function (jid) {
- return this.getGravatarUrl(jid, 100);
- },
- /**
- * Returns image URL for the avatar to be displayed on small video thumbnail
- * @param jid full MUC jid of the user for whom we want to obtain avatar URL
- */
- getThumbUrl: function (jid) {
- return this.getGravatarUrl(jid, 100);
- },
- /**
- * Returns the URL for the avatar to be displayed as contactlist item
- * @param jid full MUC jid of the user for whom we want to obtain avatar URL
- */
- getContactListUrl: function (jid) {
- return this.getGravatarUrl(jid, 30);
- },
- getGravatarUrl: function (jid, size) {
- if (!jid) {
- console.error("Get gravatar - jid is undefined");
- return null;
- }
- var id = users[jid];
- if (!id) {
- console.warn(
- "No avatar stored yet for " + jid + " - using JID as ID");
- id = jid;
- }
- if (!config.disableThirdPartyRequests) {
- return 'https://www.gravatar.com/avatar/' +
- MD5.hexdigest(id.trim().toLowerCase()) +
- "?d=wavatar&size=" + (size || "30");
- } else {
+ getAvatarUrl: function (jid) {
+ if (config.disableThirdPartyRequests) {
return 'images/avatar2.png';
+ } else {
+ if (!jid) {
+ console.error("Get avatar - jid is undefined");
+ return null;
+ }
+ var id = users[jid];
+
+ // If the ID looks like an email, we'll use gravatar.
+ // Otherwise, it's a random avatar, and we'll use the configured
+ // URL.
+ var random = !id || id.indexOf('@') < 0;
+
+ if (!id) {
+ console.warn(
+ "No avatar stored yet for " + jid + " - using JID as ID");
+ id = jid;
+ }
+ id = MD5.hexdigest(id.trim().toLowerCase());
+
+ // Default to using gravatar.
+ var urlPref = 'https://www.gravatar.com/avatar/';
+ var urlSuf = "?d=wavatar&size=100";
+
+ if (random && interfaceConfig.RANDOM_AVATAR_URL_PREFIX) {
+ urlPref = interfaceConfig.RANDOM_AVATAR_URL_PREFIX;
+ urlSuf = interfaceConfig.RANDOM_AVATAR_URL_SUFFIX;
+ }
+
+ return urlPref + id + urlSuf;
}
}
-
};
-
module.exports = Avatar;
diff --git a/modules/UI/side_pannels/contactlist/ContactList.js b/modules/UI/side_pannels/contactlist/ContactList.js
index 4e3c29466d..4fdbb2795a 100644
--- a/modules/UI/side_pannels/contactlist/ContactList.js
+++ b/modules/UI/side_pannels/contactlist/ContactList.js
@@ -32,7 +32,7 @@ function updateNumberOfParticipants(delta) {
function createAvatar(jid) {
var avatar = document.createElement('img');
avatar.className = "icon-avatar avatar";
- avatar.src = Avatar.getContactListUrl(jid);
+ avatar.src = Avatar.getAvatarUrl(jid);
return avatar;
}
@@ -181,11 +181,11 @@ var ContactList = {
contactName.html(displayName);
},
- userAvatarChanged: function (resourceJid, contactListUrl) {
+ userAvatarChanged: function (resourceJid, avatarUrl) {
// set the avatar in the contact list
var contact = $('#' + resourceJid + '>img');
if (contact && contact.length > 0) {
- contact.get(0).src = contactListUrl;
+ contact.get(0).src = avatarUrl;
}
}
diff --git a/modules/UI/videolayout/LargeVideo.js b/modules/UI/videolayout/LargeVideo.js
index b32569e48e..89243ee665 100644
--- a/modules/UI/videolayout/LargeVideo.js
+++ b/modules/UI/videolayout/LargeVideo.js
@@ -242,7 +242,7 @@ function getCameraVideoSize(videoWidth,
function updateActiveSpeakerAvatarSrc() {
var avatar = $("#activeSpeakerAvatar")[0];
var jid = currentSmallVideo.peerJid;
- var url = Avatar.getActiveSpeakerUrl(jid);
+ var url = Avatar.getAvatarUrl(jid);
if (avatar.src === url)
return;
if (jid) {
diff --git a/modules/UI/videolayout/SmallVideo.js b/modules/UI/videolayout/SmallVideo.js
index cea1e6a728..5352b22ee9 100644
--- a/modules/UI/videolayout/SmallVideo.js
+++ b/modules/UI/videolayout/SmallVideo.js
@@ -369,7 +369,7 @@ SmallVideo.prototype.showAvatar = function (show) {
if (!this.hasAvatar) {
if (this.peerJid) {
// Init avatar
- this.avatarChanged(Avatar.getThumbUrl(this.peerJid));
+ this.avatarChanged(Avatar.getAvatarUrl(this.peerJid));
} else {
console.error("Unable to init avatar - no peerjid", this);
return;
diff --git a/modules/UI/videolayout/VideoLayout.js b/modules/UI/videolayout/VideoLayout.js
index a22ac90e8e..d98a184647 100644
--- a/modules/UI/videolayout/VideoLayout.js
+++ b/modules/UI/videolayout/VideoLayout.js
@@ -1005,14 +1005,14 @@ var VideoLayout = (function (my) {
}
};
- my.userAvatarChanged = function(resourceJid, thumbUrl) {
+ my.userAvatarChanged = function(resourceJid, avatarUrl) {
var smallVideo = VideoLayout.getSmallVideo(resourceJid);
if(smallVideo)
- smallVideo.avatarChanged(thumbUrl);
+ smallVideo.avatarChanged(avatarUrl);
else
console.warn(
"Missed avatar update - no small video yet for " + resourceJid);
- LargeVideo.updateAvatar(resourceJid, thumbUrl);
+ LargeVideo.updateAvatar(resourceJid, avatarUrl);
};
my.createEtherpadIframe = function(src, onloadHandler)