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