Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
gravatar.js
Advanced tools
Readme
A promise-based Gravatar client for Node and the browser. See demo here.
Current version: 2.0.0
npm install --save gravatar.js
This library covers most of the accessible interfaces exposed by the Gravatar service and makes them accessible in the context of a browser or a Node.js application. For features requiring a bit more than simply just returning an URL to an image associated with an e-mail address, this module uses asynchronous requests accessible through a promise-based API to resolve remote resources.
The entry point of the library can be required through different means, each one depending on the environment in which the library is executed.
import gravatar from 'gravatar.js';
const gravatar = require('gravatar.js');
import gravatar from 'https://esm.sh/gravatar.js/dist/index.esm.js'
<script src="./dist/index.umd.js"></script>
To do so, you simply need to pass an e-mail address to the library :
const url = gravatar.url('foo@bar');
It is also possible to pass several options to this method in order to customize the behaviour of the Gravatar interface :
const url = gravatar.url('foo@bar', { defaultIcon: '404', size: 200 });
You will find below the list of supported parameters you can pass to the library.
Option key | Description |
---|---|
defaultIcon | The adopted behaviour when no image is associated with the given e-mail address. The default value is 404 . |
size | The size of the image in pixels. The default value is 80 pixels. |
rating | Defines whether to retrieve an avatar given its category, or rating. Take a look here for more informations. The default value is G . |
It is possible through the Gravatar API to retrieve a collection of profile objects associated with a user. Using this library it is possible to retrieve this collection using the user e-mail address.
// `profiles` is an array of profile objects associated
// with the given e-mail address.
const profiles = await gravatar.profiles('foo@bar');
Simply generating an URL given an e-mail address does not mean this URL does actually point to an existing resource. As such, this library provides an interface used to resolve the given e-mail address to a valid avatar URL.
// `url` will contain the url to the *main* thumbnail
// associated with the given e-mail address.
const url = await gravatar.resolve('foo@bar');
Similarly to when you generate an URL, you can pass an optional object as a second argument to the
.resolve
method in order to specify how you would like the avatar to be resolved. If the avatar has been resolved, it will be passed as an argument to the success callback.
FAQs
A promise-based Gravatar client for Node and the browser
The npm package gravatar.js receives a total of 420 weekly downloads. As such, gravatar.js popularity was classified as not popular.
We found that gravatar.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.