pespantelis / gravatar by pespantelis

Gravatar url builder
Package Data
Maintainer Username: pespantelis
Maintainer Contact: (Pantelis Peslis)
Package Create Date: 2015-06-22
Package Last Update: 2015-06-22
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2021-09-25 03:13:40
Package Statistics
Total Downloads: 151
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 5
Total Watchers: 1
Total Forks: 1
Total Open Issues: 0


Gravatar is a service for providing globally unique avatars.


Begin by installing this package through Composer.

composer require pespantelis/gravatar


Create and initialize a gravatar url builder.


// require the Gravatar autoloader
require 'vendor/autoload.php';

// set options (optional)
$options = [
  'size' => 256,
  'default-image' => 'identicon',
  'force-default' => false,
  'rating' => 'pg',
  'secure' => true

$gravatar = new Peslis\Gravatar\Factory($options);

Generate a Gravatar url for the requested email.

echo $gravatar->url('');

Check if the requested email has an associated image.

echo $gravatar->exists('');
// or
echo $gravatar->url('')->exists();

Override the options.

// size
echo $gravatar->url('', 256);
// or
echo $gravatar->url('')->size(256);

// secure requests
echo $gravatar->url('')->secure();

// default image
echo $gravatar->url('')->defaultImage('identicon');

// force default image
echo $gravatar->url('')->forceDefault();

// rating level
echo $gravatar->url('')->rating('pg');

Method chaining to set options.

echo $gravatar->url('', 256)->defaultImage('identicon')->rating('pg');

Laravel Extension

If you are a Laravel user, there is a here.


Gravatar is released under the MIT Licence. See the bundled LICENSE file for details.