PHP Classes


Recommend this page to a friend!
  Classes of Pierre-Henry Soria   pH2 Gravatar   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: pH2 Gravatar
Get the Gravatar user image link with an email
Author: By
Last change:
Date: 1 year ago
Size: 3,277 bytes


Class file image Download


? The simplest Gravatar PHP package

_Easy as it's supposed to be ?_

Ko Fi - Offer Me A Coffee

pH2Gravatar is lightweight gravatar library giving you an elegant way to generate gravatar profile photos from email addresses ?

? Requirements

? How to install it?

With composer:

composer require ph-7/ph2gravatar

? How to use it?

Example 1

require __DIR__ . '/vendor/autoload.php';

use PH7\PH2Gravatar\Image;

<!-- Here, we leave the default parameters. -->
<!-- By default, the image size is 200px -->
<img src="<?= Image::get('') ?>" alt="My gravatar image" />

<!-- Here, we set the gravatar image size to 400px -->
<img src="<?= Image::get('', ['size' => 400]) ?>" alt="My gravatar image" />

Example 2

require __DIR__ . '/vendor/autoload.php';

use PH7\PH2Gravatar\Image as Gravatar;

// Show the gravatar image link
echo Gravatar::get('', [
    'size' => 80,
    'rating' => 'pg',
    'display' => 'retro'

Example 3

require __DIR__ . '/vendor/autoload.php';

use PH7\PH2Gravatar\Image as GravatarImage;

$email = '';
$size = 400;

$imageUrl = GravatarImage::get($email, [
    'size' => $size,
    'display' => '404',
    'rating' => 'g'

// $imageUrl output

? Author

I'm [Pierre-Henry Soria][author-url]. A dedicated, passionate and positive software engineer ? You can keep in touch with me at _hi [[AT]] ph7 {{D0T}} me_ ?

[![@phenrysay][twitter-image]][twitter-url] [![pH-7][github-image]][github-url]

Are you enjoying my work? Offer me a coffee and boost the software development at the same time! ?

Pierre-Henry Soria

? Watch me building it!

[![Watch the video][video-thumbnail]](

? Click here to watch on YouTube

? License

pH2Gravatar is distributed under [MIT][license-url] license ? Enjoy!

<!-- GitHub's Markdown reference links --> [author-url]: [license-url]: [twitter-url]: [twitter-image]: [github-url]: [github-image]: [video-thumbnail]: