Skip to content

Commit

Permalink
Add gravatar support for profile photo
Browse files Browse the repository at this point in the history
  • Loading branch information
hifocus committed Jan 18, 2020
1 parent 8aa8c1f commit 2205cb0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions assets/js/dev-files/function.original.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,28 @@

var client;
var selected;
var scale = window.devicePixelRatio; // Change to 1 on retina screens to see blurry canvas

// Set profile photo
document.getElementById("i").style.background = "url('" + profile + "') no-repeat center/cover";
if (profile.includes('@')) { // Verify if value entered is a email
var email = profile.split("@")
var suffix = email[1];
if (suffix.includes('.')) { // Verify if the email entered is valid
var profile_url = gravatar_url + md5(profile) + "?s=96";
var profile_lg = profile_url.replace("96", "500"); // Set a large version
console.log(profile_url);
}
else {
console.log("%c Email address invaild, please entre a vaild email or image url! ", "color: red"); // Error message if email entered is invalid
console.log("%c Email 无效,请输入有效 Email 或者图片 url ", "color: red");
}
}
else {
var profile_url = profile; // If email is not entered, use whatever value entered (presumably a url)
}
// Set page favicon using jQuery
document.getElementById("i").style.background = "url('" + profile_lg + "') no-repeat center/cover"; // Set center picture
$("#favicon").attr("href", profile_url); // Set page icon

var scale = window.devicePixelRatio; // Change to 1 on retina screens to see blurry canvas

var userLang = navigator.language || navigator.userLanguage;
if (multilingual !== false) {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/dev-files/function.original.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2205cb0

Please sign in to comment.