1.1.1 • Published 4 years ago

gravatar-utils v1.1.1

Weekly downloads
37
License
ISC
Repository
github
Last release
4 years ago

Gravatar Utils

npm version

This npm package makes working with Gravatar a breeze. You don't need to worry about hashing emails, just use this package.

To import:

import { getGravatarHash, getGravatarUrl, getGravatarAvatar } from "gravatar-utils";
const userEmail = "xxxxxxxx@xxxxx.xxx";

// This function will generate the hash that gravatar uses to identify users, will return something similar to xxxxxxxxxxxxxxxxxxxxx
const userHash = getGravatarHash(userEmail);
// This function will generate the url that is accessible by any fetch library, will return something similar to https://www.gravatar.com/xxxxxxxxxxxxxxxxxxxxx.json
const gravatarProfileUrl = getGravatarUrl(userEmail);

// Fetch gravatar profile with any library
const data = await axios({
    url: gravatarProfileUrl 
});

// To get an image url for an avatar, use the getGravatarAvatar function. You can optionally specify the size in an object in the second function parameter.
<img src={getGravatarAvatar("xxxxxxxxxx@xxxx.xxx", { size: 1000} )} />

To install:

npm install gravatar-utils 

More information on the Gravatar API can be found at https://www.gravatar.com/site/implement/profiles/json/.

Type definitions are provided!

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago