elfsundae / laravel-gravatar
The easiest way to generate Gravatar avatar URL.
Installs: 7 188
Dependents: 1
Suggesters: 0
Security: 0
Stars: 37
Watchers: 2
Forks: 7
Open Issues: 0
Requires
- php: >=5.6.4
- illuminate/support: ~5.0|~6.0|~7.0|~8.0|~9.0
Requires (Dev)
- orchestra/testbench: ~3.0|~4.0|~5.0|~6.0|~7.0
- phpunit/phpunit: ~5.7|~6.0|~7.0|~8.0|~9.0
README
The easiest way to generate Gravatar avatar URL, with multiple connections support.
Installation
You can install this package using the Composer manager:
$ composer require elfsundae/laravel-gravatar
Then copy the configuration file to your application:
$ cp vendor/elfsundae/laravel-gravatar/config/gravatar.php config/gravatar.php
For Lumen, you need to load the configuration file in your bootstrap/app.php
:
$app->configure('gravatar');
API
gravatar()
is a global helper function you can use anywhere.
/** * Generate Gravatar avatar URL for the given email address. * * @param string $email Email or email hash * @param string|int $connection Connection name or image size * @param string|int $size Connection name or image size * @return string */ function gravatar($email, $connection = 'default', $size = null)
Usage
// For an email address, using the "default" connection configuration gravatar('foo@example.com'); // For an email MD5 hash, using the "default" connection configuration gravatar('b48def645758b95537d4424c84d1a9ff'); // Using the "large" connection gravatar($email, 'large'); // Using the "default" connection, and overriding "size" parameter to 100 gravatar($email, 100); // Using the "avatar" connection, and overriding "size" parameter to 100 gravatar($email, 'avatar', 100); gravatar($email, 100, 'avatar');