It's very easy to setup Gravatars on your site but before going with steps, you should know what is actually meaning of Gravatars, An avatar is a graphical representation of a user.
This service was actually created by Tom Preston-Werner to provide globally unique avatars, It could be the person's picture or random icon associated with registered emails.
There are several packages available to get Gravatar images but for this example I am going to use
Package Installationthomaswelton/laravel-gravatar
package for Laravel application.
First, You will require this package in your application via composer by running following command :
composer require thomaswelton/laravel-gravatar
Now register the service provider and its aliase in the config/app.php
'providers' => [ .... Thomaswelton\LaravelGravatar\LaravelGravatarServiceProvider::class, ],
'aliases' => [ .... 'Gravatar' => Thomaswelton\LaravelGravatar\Facades\Gravatar::class ],
Now you are ready to use it in your application by following way :
Gravatar::exists($email) will return boolean to let you know if the
$email
is associated with Gravatar.
Gravatar::src($email, $size = null, $rating = null) will return the complete URL for the Gravatar registered witl email address.
<!-- Show image with default dimensions --> <img src="{{ Gravatar::src('thomaswelton@me.com') }}"> <!-- Show image at 200px --> <img src="{{ Gravatar::src('thomaswelton@me.com', 200) }}">
0 comments