Skip to content

A Bow Framework Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

License

Notifications You must be signed in to change notification settings

bowphp/gravatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gravatar for Bow Framework

Total Downloads Latest Stable Version License

Installation

First, pull in the package through Composer via the command line:

composer require bowphp/gravatar

Usage

Within your controllers or views, you can use

Gravatar::get('[email protected]');

This will return the URL to the gravatar image of the specified email address. In case of a non-existing gravatar, it will return return a URL to a placeholder image. You can set the type of the placeholder in the configuration option fallback. For more information, visit gravatar.com

Alternatively, you can check for the existence of a gravatar image by using

Gravatar::exists('[email protected]');

This will return a boolean (true or false).

Or you can pass a url to a custom image using the fallback method:

Gravatar::fallback('http://urlto.example.com/avatar.jpg')->get('[email protected]');

Configuration

You can create different configuration groups to use within your application and pass the group name as a second parameter to the get-method:

There is a default group in config/gravatar.php which will be used when you do not specify a second parameter.

If you would like to add more groups, feel free to edit the config/gravatar.php file. For example:

return [
	'default' => [
		'size'   => 80,
		'fallback' => 'mm',
		'secure' => false,
		'maximumRating' => 'g',
		'forceDefault' => false,
		'forceExtension' => 'jpg',
 	],

 'small-secure' => [
    'size'   => 30,
    'secure' => true,
	],

	'medium' => [
    'size'   => 150,
	],
];

then you can use the following syntax:

Gravatar::get('[email protected]', 'small-secure'); // will use the small-secure group
Gravatar::get('[email protected]', 'medium'); // will use the medium group
Gravatar::get('[email protected]', 'default'); // will use the default group
Gravatar::get('[email protected]'); // will use the default group

Alternatively, you could also pass an array directly as the second parameter as inline options. So, instead of passing a configuration key, you pass an array, which will be merged with the default group:

Gravatar::get('[email protected]', ['size' => 200]); 

About

A Bow Framework Gravatar package for retrieving gravatar image URLs or checking the existance of an image.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages