React Gravatar

Code on Github

React component for rendering a gravatar profile image. Adjusts automatically for retina displays.

Install

npm install --save react-gravatar

Usage

import Gravatar from 'react-gravatar'
  <Gravatar email="a-email@example.com" />

A few examples

<Gravatar email="mathews.kyle@gmail.com" />Gravatar for mathews.kyle@gmail.com<Gravatar email="mathews.kyle@gmail.com" size={150} />Gravatar for mathews.kyle@gmail.com

For emails without a gravatar, use the retro default. You can override this by passing in a different 'default' prop. See https://en.gravatar.com/site/implement/images/ for options.

<Gravatar email="blah@blah.com" />Gravatar for blah@blah.com

Override all defaults

<Gravatar email="blahblah@blah.com" size={150} rating="pg" default="monsterid" className="CustomAvatar-image" />Gravatar for blahblah@blah.com

Props

  • email: React.PropTypes.string — email address to generate Gravatar image for.
  • md5: React.PropTypes.string — Optionally just pass in a precomputed md5 hash instead of an email.
  • size: React.PropTypes.number — Size in pixels of image to generate. Images are always square. Defaults to 50
  • rating: React.PropTypes.string — rating to use. Defaults to 'g'
  • default: React.PropTypes.string — Pick the type of fallback image to use. Defaults to 'retro'
  • className: React.PropTypes.string — Add a className to the generated image.
  • style: React.PropTypes.object — Set styles on the image.
  • protocol: React.PropTypes.string — Use different protocol (http://, https://, etc.) Defaults to '//'