Socket
Socket
Sign inDemoInstall

react-awesome-gravatar

Package Overview
Dependencies
15
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-awesome-gravatar

Just another react gravatar component


Version published
Weekly downloads
726
increased by47.86%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-awesome-gravatar

Installation

npm install react-awesome-gravatar --save
yarn add react-awesome-gravatar

Usage

Gravatar component

import Gravatar from 'react-awesome-gravatar';

<Gravatar email={email}>
  { url => (<img src={url} />) }
</Gravatar>
// Should generate an <img /> tag with the correct gravatar profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8
import { GravatarOptions } from 'react-awesome-gravatar';
const options: GravatarOptions = {
    size: 50,
}; // check below for all available options
<Gravatar email="example@example.com" options={ options }>
  { url => (<img src={url} />) }
</Gravatar>
// Should generate an <img /> tag with the correct gravatar profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=50

Just the function

If you just need the URL to the profile image of gravatar, you can omit the use of the component and call the function that the component calls directly.

import { getGravatarUrl } from 'react-awesome-gravatar';

const profileUrl = getGravatarUrl('example@example.com');
// profileUrl has the profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8

import { getGravatarUrl, GravatarOptions } from 'react-awesome-gravatar';
const options: GravatarOptions = {
    size: 50,
}; // check below for all available options

const profileUrl = getGravatarUrl('example@example.com', options);
//  profileUrl has the profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=50

Options

interface GravatarOptions {
  size?: number;
  default?: '404'|'mp'|'identicon'|'monsterid'|'wavatar'|'retro'|'robohash'|'blank';
  defaultUrl?: string;
  forcedefault?: 'y';
  rating?: 'g'|'pg'|'r'|'x';
}

The options match 1:1 to the Gravatar API except for defaultUrl which if present set the Gravatar default to it.

const options: GravatarOptions = {
    defaultUrl: 'http://example.com/image.png',
}
const profileUrl = getGravatarUrl('example@example.com', options);
//  profileUrl has the profile url: https://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?default=http://example.com/image.png

Tests

Tests are configured with Jest, to run them use:

npm run test

Keywords

FAQs

Last updated on 28 Aug 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc