Увійти Реєстрація
Блог Серії
Кар'єра
Вакансії Компанії
Навчання
Документація Співбесіди Тестування Відео
Екосистема
Пакети Ресурси Проєкти Інструменти Події
Інше
Про нас Реклама

Gravatar

creativeorange/gravatar
v1.0.26 13 546 8.4M 20 березня 2026
На GitHub

Laravel пакет для отримання URL-адрес аватарів Gravatar та перевірки наявності зображення.

8

Поділитись

README

Gravatar for Laravel 5 - 12

Total Downloads Latest Stable Version License

Installation

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

composer require creativeorange/gravatar ~1.0

or add the following to your composer.json file and run composer update.

"require": {
    "creativeorange/gravatar": "~1.0"
}

Then include the service provider within (Laravel 5.3 or below) app/config/app.php.

'providers' => [
    'Creativeorange\Gravatar\GravatarServiceProvider'
];

If using Laravel 5.4, include service provider withing config/app.php

'providers' => [
    Creativeorange\Gravatar\GravatarServiceProvider::class
];

If you want to use the facade, add this to de bottom of app/config/app.php And, for convenience, add a facade alias to this same file at the bottom:

'aliases' => [
    'Gravatar' => 'Creativeorange\Gravatar\Facades\Gravatar',
];

If you are using Laravel 5.4 or greater, add as follows, add to config/app.php

'aliases' => [
    'Gravatar' => Creativeorange\Gravatar\Facades\Gravatar::class,
];

Finally, publish the config by running the php artisan vendor:publish command

Usage

Within your controllers or views, you can use

    Gravatar::get('email@example.com');

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@example.com');

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@example.com');

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 array(
	'default' => array(
		'size'   => 80,
		'fallback' => 'mm',
		'secure' => false,
		'maximumRating' => 'g',
		'forceDefault' => false,
		'forceExtension' => 'jpg',
	),
	'small-secure' => array (
	    'size'   => 30,
	    'secure' => true,
	),
	'medium' => array (
	    'size'   => 150,
	)
);

then you can use the following syntax:

Gravatar::get('email@example.com', 'small-secure'); // will use the small-secure group
Gravatar::get('email@example.com', 'medium'); // will use the medium group
Gravatar::get('email@example.com', 'default'); // will use the default group
Gravatar::get('email@example.com'); // 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@example.com', ['size'=>200]); 

Коментарі

Увійдіть, щоб залишити коментар

Будьте першим, хто залишить коментар!

Схожі пакети

Laravel Permission

spatie/laravel-permission

Управління дозволами та правами доступу для Laravel 12 та новіших версій.

12,962 8.3.0 13 29

Laravel Activitylog

spatie/laravel-activitylog

Простий логер активності для моніторингу користувачів вашого веб-сайту або додатку.

5,895 5.1.1 13 21

Laravel Socialite

laravel/socialite

Вхід через Google, GitHub, Facebook, X та інші OAuth-провайдери. Ховає різницю між їхніми API за єдиним інтерфейсом; десятки додаткових провайдерів доступні через Socialite Providers.

5,746 v5.30.0 13 2

Laravel Jetstream

laravel/jetstream

Розширений стартовий набір поверх Fortify: команди, керування профілем, API-токени, двофакторка та сесії пристроїв. Для проєктів, де багатокористувацькі команди потрібні від першого дня.

4,056 v5.5.3 13 3

Bouncer

josephsilber/bouncer

Пакет для управління ролями та дозволами через Eloquent ORM.

3,579 v1.0.4 13 12

Laravel Passport

laravel/passport

Повноцінний OAuth2-сервер для Laravel за лічені хвилини. Потрібен, коли ваш API споживають сторонні застосунки і треба видавати їм токени з grant-флоу.

3,412 v13.7.6 13 3