How to show profile photos on a public Kumu map without revealing email addresses
On this recent post I explained how I used Google Forms + custom scripts to make a user-editable Kumu map from a Google Sheet. That map uses another trick I want to share: how to show profile photos without revealing email addresses.
Note: this post is more technical than usual. It assumes a working knowledge of Kumu, and at least a passing familiarity with custom scripts in Google Sheets.
Kumu uses Gravatar, the [G]lobally [R]ecognised Avatar service. You put an “email” attribute on a Kumu element, feed it an email address, and it will return the profile photo that Gravatar has on file for that email address. Easy!
Problem: I want to use Gravatar, but I don’t want to put people’s email addresses on a public map.
Solution: I generate the image path using a custom script in the Sheet, and pass that to the public map, instead of passing emails.
Gravatar uses MD5 encryption to hide your email address from the world. So instead of looking up ‘rich@loomio.org’ to find my picture, you need to look up ‘d5039eb7649c89379ed0715e41a68310’. This alphanumeric string is the result of running the MD5 algorithm on ‘rich@loomio.org’. With that, you can visit this path and see a wee photo of my lovely face: https://s.gravatar.com/avatar/9f0b6573d7bd04b70cf0ca8b492dcd51
To achieve this in Google Sheets, I added this custom function called MD5:
function MD5 (input) {
var rawHash = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, input);
var txtHash = '';
for (i = 0; i < rawHash.length; i++) {
var hashVal = rawHash[i];
if (hashVal < 0) {
hashVal += 256;
}
if (hashVal.toString(16).length == 1) {
txtHash += '0';
}
txtHash += hashVal.toString(16);
}
Utilities.sleep(100)
return txtHash;
}
Finally I stitch the complete URL together in the cell, like so:
=concatenate(“https://s.gravatar.com/avatar/", md5("rich@loomio.org")
Ta da! An easy way to get profile photos without revealing email addresses 🤓
p.s. if you want to support my writing, you can throw some coins in my hat on Patreon 😍