Package Data | |
---|---|
Maintainer Username: | fakiolinho |
Maintainer Contact: | info@marios-development.com (Foinikas) |
Package Create Date: | 2014-07-24 |
Package Last Update: | 2014-07-28 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:18:33 |
Package Statistics | |
---|---|
Total Downloads: | 601 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Laravel Gravatar is a very easy way to call gravatars with fallback images quite fast and efficiently while using Laravel 4 framework.
Begin by installing this package through Composer. Edit your project's composer.json file to require foinikas/gravatar.
"require": {
"foinikas/gravatar": "dev-master"
}
Next, update Composer from the Terminal:
composer update
Once this operation completes, the final step is to add the service provider. Open app/config/app.php
, and add a new item to the providers array.
'Foinikas\Gravatar\GravatarServiceProvider'
Do not worry about registering any Facade as it will register automatically a new Facade named Gravatar
for you.
Provided methods:
Ready to call your first gravatar? Ok just create a gravatar image:
Gravatar::image('my@email.com');
or maybe just a gravatar url is ok:
Gravatar::url('my@email.com');
That's it. Your gravatar was created!
In case you need only the hashed email address of yours:
Gravatar::hash('my@email.com');
Easy enough right?
Gravatar's image
method can accept quite a few options:
Gravatar::image($email, array $attrs = null, $size = 50, $default = null, $r = 'g', $secure = false);
Gravatar's url
method can accept almost the same except for the $attrs
array:
Gravatar::url($email, $size = 50, $default = null, $r = 'g', $secure = false);
Gravatar's hash
method accepts only the email address as a parameter:
Gravatar::hash($email);
User's email address.
Note: If an invalid email address is provided an exception will be thrown.
Default value: not provided
Attributes for the created img tag. Usage:
['class' => 'myClass', 'id' => 'myId'];
Default value: null
An integer that demonstrates the gravatar's size you want.
Default value: 50
This is the fallback image in case there is not a valid gravatar for the provided email address. This can be either the default Gravatar logo if default parameter is left blank or can be one of the many options Gravatar's api provides:
'404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank'
or also it could be a custom image's url you may choose to provide:
'img/myimage.jpg'
In case you provide a custom image then the package shall create a full path to it using Laravel's URL::asset()
method.
Default value: null (Gravatar logo)
Gravatar's rating option. Gravatar's api options:
'g', 'pg', 'r', 'x'
Default value: 'g'
If you're displaying Gravatars on a page that is being served over SSL, then you'll want to serve your Gravatars via SSL as well. To achieve this just set this to true.
Default value: false
All code created by foinikas is open-sourced software licensed under the MIT license
For more information about the default options Gravatar's API provides visit Gravatar