Package Data | |
---|---|
Maintainer Username: | forxer |
Maintainer Contact: | forxer@gmail.org (Vincent Garnier) |
Package Create Date: | 2017-08-07 |
Package Last Update: | 2024-05-26 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:02:33 |
Package Statistics | |
---|---|
Total Downloads: | 25,119 |
Monthly Downloads: | 129 |
Daily Downloads: | 8 |
Total Stars: | 41 |
Total Watchers: | 4 |
Total Forks: | 9 |
Total Open Issues: | 0 |
This package provides an easy Gravatar integration in a Laravel project.
This package is built on top of forxer/Gravatar.
Install through composer:
composer require forxer/laravel-gravatar
In Laravel 5.5 the service provider will automatically get registered.
In older versions of the framework just add the service provider
to the array of providers in config/app.php
:
// config/app.php
'provider' => [
//...
forxer\LaravelGravatar\ServiceProvider::class,
//...
];
In Laravel 5.5 the facade will automatically get registered.
In older versions of the framework just add the facade
to the array of aliases in config/app.php
:
// config/app.php
'aliases' => [
//...
'Gravatar' => forxer\LaravelGravatar\Facade::class,
//...
];
With the helper:
<img src="{{ gravatar('email@example.com') }}">
// or
<img src="{{ gravatar()->image('email@example.com') }}">
// or
<img src="{{ gravatar()->avatar('email@example.com') }}">
Or with the facade:
<img src="{{ Gravatar::image('email@example.com') }}">
// or
<img src="{{ Gravatar::avatar('email@example.com') }}">
Or with the service injection:
@inject('gravatar', 'forxer\LaravelGravatar\Gravatar')
<img src="{{ $gravatar->image('email@example.com') }}">
// or
<img src="{{ $gravatar->avatar('email@example.com') }}">
You can set optional parameters:
<img src="{{ gravatar('email@example.com')->s(120)->e('png') }}">
// or
<img src="{{ gravatar('email@example.com')->size(120)->extension('png') }}">
// or
<img src="{{ gravatar('email@example.com')->setSize(120)->setExtension('png') }}">
There is several available parameters:
setSize()
size()
or s()
setDefaultImage()
size()
or s()
setForceDefault()
defaultImage()
or d()
setMaxRating()
rating()
or r()
setExtension()
extension()
or e()
For more details, please refer to the forxer/Gravatar documentation.
It is possible to define groups of defaults, known as presets. This is helpful if you have standard settings that you use throughout your app. In the configuration file, you can define as many avatar preset as you wish and a default preset to be used.
First, publish the config file of the package using artisan:
php artisan vendor:publish --provider="forxer\LaravelGravatar\ServiceProvider"
Then, define a preset in the configuration file:
'my_preset' => [
'size' => 120,
'extension' => 'png',
],
Finally, use it in your views by specifying its name.
<img src="{{ gravatar('email@example.com', 'my_preset') }}">