utils/src/misc.ts

14 lines
423 B
TypeScript
Raw Normal View History

2024-02-07 01:33:07 -05:00
import {md5} from './string';
/**
* Get profile image from Gravatar
*
* @param {string} email Account email address
* @param {string} def Default image, can be a link or '404', see: https://docs.gravatar.com/general/images/
2024-02-07 01:33:07 -05:00
* @returns {string} Gravatar URL
*/
2024-03-20 20:44:53 -04:00
export function gravatar(email: string, def='mp') {
2024-02-07 01:33:07 -05:00
if(!email) return '';
return `https://www.gravatar.com/avatar/${md5(email)}?d=${def}`;
2024-02-07 01:33:07 -05:00
}