Updated gravatar function to supply default image
All checks were successful
Build / Build NPM Project (push) Successful in 20s
Build / Tag Version (push) Successful in 4s
Build / Publish (push) Successful in 8s

This commit is contained in:
Zakary Timson 2024-03-20 19:26:13 -04:00
parent d52f9cfdc3
commit f6b0e63751
2 changed files with 4 additions and 3 deletions

View File

@ -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",

View File

@ -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 */