gravatar

所属分类:前端开发
开发工具:PHP
文件大小:0KB
下载次数:0
上传日期:2015-12-09 07:41:26
上 传 者sh-1993
说明:  laravel 5的化身发生器,
(Avatar Generator for laravel 5,)

文件列表:
.editorconfig (312, 2015-12-08)
CHANGELOG.md (221, 2015-12-08)
CONDUCT.md (2150, 2015-12-08)
CONTRIBUTING.md (1336, 2015-12-08)
LICENSE.md (1129, 2015-12-08)
composer.json (759, 2015-12-08)
src/ (0, 2015-12-08)
src/Facades/ (0, 2015-12-08)
src/Facades/Gravatar.php (300, 2015-12-08)
src/Gravatar.php (4638, 2015-12-08)
src/GravatarServiceProvider.php (1129, 2015-12-08)
src/helpers.php (58, 2015-12-08)

# Laravel Gravatar This package provides you a simple to generate avatar. - [Installation](https://github.com/hilabs/gravatar/blob/master/#installation) - [Registering the Package](https://github.com/hilabs/gravatar/blob/master/#registering-the-package) - [Usage](https://github.com/hilabs/gravatar/blob/master/#usage) ## Installation Via Composer ``` bash $ composer require hilabs/gravatar ``` ## Registering the Package After you have installed, open your Laravel config file `config/app.php` and add the following lines. In the `providers` array add the service providers for this package. ``` php Hilabs\Gravatar\GravatarServiceProvider::class, ``` Add the facade of this package to the `aliases` array. ``` php 'Gravatar' => Hilabs\Gravatar\Facades\Gravatar::class, ``` ## Usage - [Basic Usage](https://github.com/hilabs/gravatar/blob/master/#basic-usage) - [Using array parameters](https://github.com/hilabs/gravatar/blob/master/#using-array-parameters) - [Generating HTM avatar code](https://github.com/hilabs/gravatar/blob/master/#generating-htm-avatar-code) #### Basic Usage Generating avatar with default settings is very simple and all you have to do is to call ``make()`` method with user email as a paramterer: ```php url(); ?> ``` If you want to customize avatar a little bit you can set some more parameters using additional methods like ``size()``, ``rating()``, ``defaultImage()``. ```php size('220'); // Maximum rating (inclusive) [ g | pg | r | x ] // defaults to 'g' $gravatar->rating('g'); // Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] // You can also specify url to your own default avatar image // defaults to 'mm' $gravatar->defaultImage('mm'); // set Gravatar to build urls with https [true = use https, false = ise http] // defaults to 'false' $gravatar->secured( true ); // get gravatar url as a string $url = $gravatar->url(); ?> ``` You can also chain all methods: ```php size('220')->rating('g')->defaultImage('mm')->url(); ?> ``` ### Using array parameters You can do this by passing array with parameters to ``make()`` method: ```php $email, 'size' => 220] )->url(); // create a gravatar object with some other additional parameters $url = Gravatar::make( [ 'email' => $email, 'size' => 220, 'defaultImage' => 'mm', 'rating' => 'g', 'secured' => true ])->url(); ?> ``` #### Generating HTM avatar code With Gravatar you can get url string of user avatar by calling ``url()`` method but also you can generate full html code by calling ``html()`` method instead of ``url()``. ```php size('120'); // get gravatar html code $html = $gravatar->html(); ?> ``` If you want to have more controll over the returned html code you can pass some additional html attributes to html() method, for examle: ```php html( ['class' => 'avatar', 'id' => 'user123' ] ); ?> ```

近期下载者

相关文件


收藏者