PHP Classes

How Can PHP Get Gravatar URL for a User Image Using pH2 Gravatar: Get the Gravatar user image link with an email

Recommend this page to a friend!
  Info   View files Documentation   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-11-03 (3 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 18 Not yet ranked
Version License PHP version Categories
ph2gravatar 1.0GNU General Publi...5PHP 5, Graphics, Web services
Description Author

This class can get the Gravatar user image link with an email.

It can take as a parameter the email address of a given user with a record on the Gravatar site.

The class returns the URL for an image with a given size served by the Gravatar for the user with the specified email address.

Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 40 packages by
Country: United Kingdom
Age: 32
All time rank: 39917 in United Kingdom
Week rank: 17 Up1 in United Kingdom Up
Innovation award
Innovation award
Nominee: 15x

Winner: 3x

Details

pH2Gravatar

? 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. https://en.gravatar.com/site/implement/images/ -->
<!-- By default, the image size is 200px -->
<img src="<?= Image::get('me@test.email') ?>" alt="My gravatar image" />


<!-- Here, we set the gravatar image size to 400px -->
<img src="<?= Image::get('me@test.email', ['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('me@test.email', [
    'size' => 80,
    'rating' => 'pg',
    'display' => 'retro'
]);
// https://www.gravatar.com/avatar/9c47a7bb2aec6e61df372a8f8446ed9d?s=80&r=pg&d=retro

Example 3

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

use PH7\PH2Gravatar\Image as GravatarImage;

$email = 'me@myemail.com';
$size = 400;

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

// $imageUrl output
// https://www.gravatar.com/avatar/4995f3f0b59f4abfda86e74f92896f3b?s=400&r=g&d=404

? 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]](https://www.youtube.com/watch?v=DeGYaRkStaE)

? Click here to watch on YouTube

? License

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

<!-- GitHub's Markdown reference links --> [author-url]: https://pierrehenry.be [license-url]: https://opensource.org/licenses/MIT [twitter-url]: https://twitter.com/phenrysay [twitter-image]: https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white [github-url]: https://github.com/pH-7 [github-image]: https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white [video-thumbnail]: https://i1.ytimg.com/vi/DeGYaRkStaE/hqdefault.jpg

  Files folder image Files  
File Role Description
Files folder image.github (1 file, 1 directory)
Files folder imagemedia (1 file)
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file save-code.sh Data Auxiliary data

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)
  Accessible without login Plain text file FUNDING.yml Data Auxiliary data

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file test.yml Data Auxiliary data

  Files folder image Files  /  media  
File Role Description
  Accessible without login Image file kofi-logo.png Icon Icon image

  Files folder image Files  /  src  
File Role Description
  Plain text file Image.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file ImageTest.php Class Class source

 Version Control Unique User Downloads  
 100%
Total:18
This week:0