1. Go to this page and download the library: Download forxer/gravatar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Gravatar\Image;
use Gravatar\Profile;
if (! function_exists('gravatar')) {
/**
* Return a new Gravatar Image instance.
*
* @param string|null $email
* @return Image
*/
function gravatar(?string $email = null): Image
{
return new Image($email);
}
}
if (! function_exists('gravatar_profile')) {
/**
* Return a new Gravatar Profile instance.
*
* @param string|null $email
* @return Profile
*/
function gravatar_profile(?string $email = null): Profile
{
return new Profile($email);
}
}
et a Gravatar image instance:
$image = gravatar('[email protected]');
// return: Gravatar\Image
// Get a Gravatar image URL:
$imageUrl = gravatar('[email protected]')->url();
// return: //www.gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e
// Show a Gravatar image URL:
echo gravatar('[email protected]');
// output: //www.gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e
// Get a Gravatar profile instance:
$profile = gravatar_profile('[email protected]');
// return: Gravatar\Profile
// Get a Gravatar profile URL:
echo gravatar_profile('[email protected]');
// output: https//www.gravatar.com/5658ffccee7f0ebfda2b226238b1eb6e
Gravatar\Gravatar;
// Get a Gravatar image instance:
$image = Gravatar::image('[email protected]');
// return: Gravatar\Image
// Get a single Gravatar image URL:
$imageUrl = Gravatar::image('[email protected]')->url();
// return: //www.gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e
// Show a single Gravatar image URL:
echo Gravatar::image('[email protected]');
// output: //www.gravatar.com/avatar/5658ffccee7f0ebfda2b226238b1eb6e
// Get a Gravatar profile instance:
$profile = Gravatar::profile('[email protected]');
// return Gravatar\Profile
// Get a Gravatar profile URL:
echo Gravatar::profile('[email protected]');
// output: https//www.gravatar.com/5658ffccee7f0ebfda2b226238b1eb6e
Gravatar\Gravatar;
$emails = ['[email protected]', '[email protected]','[email protected]', /* ... */ ];
// Get multiples Gravatar images:
foreach (Gravatar::images($emails) as $image) {
echo $image;
}
// Get multiples Gravatar profiles:
foreach (Gravatar::profiles($emails) as $profile) {
echo $profile;
}
Gravatar\Image as GravatarImage;
use Gravatar\Profile as GravatarProfile;
// emails list
$emails = ['[email protected]', '[email protected]','[email protected]', /* ... */ ];
// Get multiples Gravatar images with size and default image:
$gravatarImage = new GravatarImage();
$gravatarImage
->setSize(120)
->setDefaultImage('mp');
foreach ($emails as $email) {
echo $gravatarImage->email($email)->url();
}
// Get multiples Gravatar profiles in JSON
$gravatarProfile = new GravatarProfile();
$gravatarProfile->setFormat('json');
foreach ($emails as $email) {
echo $gravatarProfile->email($email)->url();
}
// pass it as argument of the helper
$gravatarImage = gravatar($email);
// the first argument of `Gravatar::image()` and `Gravatar::images()`
$gravatarImage = Gravatar::image($email);
$gravatarImages = Gravatar::images($emails);
// or pass it to the `Gravatar\Image` constructor
$gravatarImage = new Gravatar\Image($email);
// or use the `setEmail()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar();
$gravatarImage->setEmail($email);
$gravatarImage = new Gravatar\Image();
$gravatarImage->setEmail($email);
// or the `email()` helper method of a `Gravatar\Image` instance
$gravatarImage = gravatar();
$gravatarImage->email($email);
$gravatarImage = new Gravatar\Image();
$gravatarImage->email($email);
// pass it as argument of the helper
$gravatarProfile = gravatar_profile($email);
// the first argument of `Gravatar::profile()` and `Gravatar::profiles()`
$gravatarProfile = Gravatar::profile($email);
$gravatarProfiles = Gravatar::profiles($emails);
// or pass it to the `Gravatar\Profile` constructor
$gravatarProfile = new Gravatar\Profile($email);
// or use the `setEmail()` method of a `Gravatar\Profile` instance
$gravatarProfile = gravatar_profile();
$gravatarProfile->setEmail($email);
$gravatarProfile = new Gravatar\Profile();
$gravatarProfile->setEmail($email);
// or the `email()` helper method of a `Gravatar\Profile` instance
$gravatarProfile = gravatar_profile();
$gravatarProfile->email($email);
$gravatarProfile = new Gravatar\Profile();
$gravatarProfile->email($email);
// pass the size as second argument of `Gravatar::image()` and `Gravatar::images()`
$gravatarImage = Gravatar::image($email, 120);
$gravatarImages = Gravatar::images($emails, 120);
// or use the `setSize()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->setSize(120);
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->setSize(120);
// or the `size()` helper method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->size(120);
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->size(120);
// or its alias `s()` (as in the generated query string)
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->s(120);
// call the `getSize()` method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->getSize();
$gravatarImage = new Gravatar\Image();
$gravatarImage->getSize();
// or the `size()` helper method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->size();
$gravatarImage = new Gravatar\Image();
$gravatarImage->size();
// or its alias `s()`
$gravatarImage = gravatar();
$gravatarImage->s();
$gravatarImage = new Gravatar\Image();
$gravatarImage->s();
// pass the default Gravatar image as third argument of `Gravatar::image()` and `Gravatar::images()`
$gravatarImage = Gravatar::image($email, null, 'mp');
$gravatarImages = Gravatar::images($emails, null, 'mp');
// or with named parameters
$gravatarImage = Gravatar::image($email, defaultImage: 'mp');
$gravatarImages = Gravatar::images($emails, defaultImage: 'mp');
// or use the `setDefaultImage()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->setDefaultImage('mp');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->setDefaultImage('mp');
// or the `defaultImage()` helper method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->defaultImage('mp');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->defaultImage('mp');
// or its alias `d()` (as in the generated query string)
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->d('mp');
// call the `getDefaultImage()` method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->getDefaultImage();
$gravatarImage = new Gravatar\Image();
$gravatarImage->getDefaultImage();
// or the `defaultImage()` helper method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->defaultImage();
$gravatarImage = new Gravatar\Image();
$gravatarImage->defaultImage();
// or its alias `d()`
$gravatarImage = gravatar();
$gravatarImage->d();
$gravatarImage = new Gravatar\Image();
$gravatarImage->d();
// pass the Gravatar image max rating as fourth argument of `Gravatar::image()` and `Gravatar::images()`
$gravatarImage = Gravatar::image($email, null, null, 'g');
$gravatarImages = Gravatar::images($emails, null, null, 'g');
// or with named parameters
$gravatarImage = Gravatar::image($email, rating: 'g');
$gravatarImages = Gravatar::images($emails, rating: 'g');
// or use the `setMaxRating()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->setMaxRating('g');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->setMaxRating('g');
// or the `maxRating()` helper method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->maxRating('g');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->maxRating('g');
// or its alias `r()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->r('g');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->r('g');
// call the `getMaxRating()` method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->getMaxRating();
$gravatarImage = new Gravatar\Image();
$gravatarImage->getMaxRating();
// or the `maxrating()` helper method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->maxrating();
$gravatarImage = new Gravatar\Image();
$gravatarImage->maxrating();
// or its alias `r()`
$gravatarImage = gravatar();
$gravatarImage->r();
$gravatarImage = new Gravatar\Image();
$gravatarImage->r();
// pass the Gravatar image file-type extension as fifth argument of `Gravatar::image()` and `Gravatar::images()`
Gravatar::image($email, null, null, null, 'jpg');
Gravatar::images($emails, null, null, null, 'jpg');
// or with named parameters
$gravatarImage = Gravatar::image($email, extension: 'jpg');
$gravatarImages = Gravatar::images($emails, extension: 'jpg');
// or use the `setExtension()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->setExtension('jpg');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->setExtension('jpg');
// or the `extension()` helper method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->extension('jpg');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->extension('jpg');
// or its alias `e()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->e('jpg');
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->e('jpg');
// call the `getExtension()` method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->getExtension();
$gravatarImage = new Gravatar\Image();
$gravatarImage->getExtension();
// or the `extension()` helper method of a `Gravatar\Image` instance without argument
$gravatarImage = gravatar();
$gravatarImage->getExtension();
$gravatarImage = new Gravatar\Image();
$gravatarImage->extension();
// or its alias `e()`
$gravatarImage = gravatar();
$gravatarImage->getExtension();
$gravatarImage = new Gravatar\Image();
$gravatarImage->e();
// to force to always use the default image, set the sixth argument of `Gravatar::image()` and `Gravatar::images()` to `true`
Gravatar::image($email, null, null, null, null, true);
Gravatar::images($emails, null, null, null, null, true);
// or with named parameters
$gravatarImage = Gravatar::image($email, forceDefault: true);
$gravatarImages = Gravatar::images($emails, forceDefault: true);
// or use the `setForceDefault()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->setForceDefault(true);
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->setForceDefault(true);
// or the `forceDefault()` helper method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->forceDefault(true);
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->forceDefault(true);
// or its alias `f()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->f(true);
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->f(true);
// or use the `enableForceDefault()` method of a `Gravatar\Image` instance
$gravatarImage = gravatar($email);
$gravatarImage->setForceDefault(true);
$gravatarImage = new Gravatar\Image($email);
$gravatarImage->enableForceDefault();
// pass the Gravatar profile format as second argument of `Gravatar::profile()` and `Gravatar::profiles()`
Gravatar::profile($email, 'json');
// or use the `setFormat()` method of `Gravatar\Profile` instance
$gravatarProfile = new Gravatar\Profile($email);
$gravatarProfile->setFormat('json');
// or the `format()` helper method of a `Gravatar\Profile` instance
$gravatarProfile = new Gravatar\Profile($email);
$gravatarProfile->format('json');
// or its alias `f()` (as in the generated query string)
$gravatarProfile = new Gravatar\Profile($email);
$gravatarProfile->f('json');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.