Updated gravatar function to supply default image
This commit is contained in:
parent
d52f9cfdc3
commit
f6b0e63751
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ztimson/js-utilities",
|
||||
"version": "0.3.6",
|
||||
"version": "0.3.7",
|
||||
"description": "JavaScript Utility library",
|
||||
"author": "Zak Timson",
|
||||
"license": "MIT",
|
||||
|
@ -16,11 +16,12 @@ export function formEncode(data: any): 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/
|
||||
* @returns {string} Gravatar URL
|
||||
*/
|
||||
export function gravatar(email: string) {
|
||||
export function gravatar(email: string, def='md') {
|
||||
if(!email) return '';
|
||||
return `https://www.gravatar.com/avatar/${md5(email)}`;
|
||||
return `https://www.gravatar.com/avatar/${md5(email)}?d=${def}`;
|
||||
}
|
||||
|
||||
/** Parts of a URL */
|
||||
|
Loading…
Reference in New Issue
Block a user