Package Exports
- gravatar-api
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gravatar-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
gravatar-img
Node module to consume images and profiles from gravatar.
nodejs-gravatar makes it easy to build gravatar image url's to access a user's gravatar directly.
To Install
Using node package manager
Example
npm install --save gravatar-img
To Use
Simply add the following require statement to import the module and then call the imageUrl method, passing the email address of the user to generate a gravatar URL.
Example
var gravatar = require('gravatar-api');
var options = {
email: 'test@gmail.com'
}
newUser.avatar = gravatar.imageUrl(options);
You can also specify the size of the image with the following (or any valid gravatar option)
Example
var options = {
email: 'test@gmail.com',
parameters: { "size": "200" }
}
newUser.avatar = gravatar.imageUrl(options);
A valid size is between 1 - 2048.
For more options, see gravatar documentation
Secure Endpoint
You can specify the retrieving the secure version of the URL by passing a third BOOLEAN
parameter
Example
var options = {
email: 'test@gmail.com',
parameters: { "size": "200" },
secure: true
}
newUser.avatar = gravatar.imageUrl(options);
Gravatar Profile URLs
You can retrieve a users profile url.
see the gravatar docs for more information on what parameters can be used
Example
var options = {
email: 'test@gmail.com',
type: 'json', // Defailt: json, Available Types: 'json', 'xml', 'qr', 'php', 'vcf'
parameters: {'callback': 'doSomething' }, //optional
secure: true
}
newUser.avatar = gravatar.getProfileUrl(options);
Notes
- compatible with react-native