Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-gravatar

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-gravatar

A vanilla JS library to get a user's gravatar and if it doesn't exist provides one different from gravatar default

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

JS Gravatar

npm package

Demo

Vanilla JS

Copy dist/js-gravatar.js into your library folder Load it into your HTML script

<script type="text/javascript" src="path/to/js-gravatar.js"></script>

You can use the UNPKG link https://unpkg.com/js-gravatar@1.1.2/dist/js-gravatar.js. Remember to update the package number to the most recent.

Call the method with its options.

JsGravatar({ element, numberOfDice: 2, callback });

With npm (and CommonJS builder)

Install with npm.

npm install --save js-gravatar

Install with yarn.

yarn add js-gravatar

import the library

ES5

const JsGravatar = require('js-gravatar');

ES6

import JsGravatar from 'js-gravatar';

Call the method

JsGravatar({ email: 'user@email.com', size: 10, defaultImage: 'identicon' });
JsGravatar({ email: 'user@email.com', defaultImage: 'monsterid' });

Parameter Definitions

  • email: Email address of the user to generate gravatar for - string
  • md5Hash: Optional: MD5 hash of the email above. If email is provided, md5hash will be ignored. If neither email nor md5hash is provided, the library will throw en error - string
  • size: Optional: The size of the image to be displayed. Should be from 1 to 2048 - number
  • defaultImage: What image should be used if email does not have a gravatar. See options below - string

Defaultimage Options - ['404', 'mp', 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash', 'blank']

License

MIT License

Keywords

FAQs

Package last updated on 02 May 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc