parsidev/

gravatar

Laravel 5.6 的 Gravatar 包

2.0.2 2021-01-01 10:20 UTC

This package is auto-updated.

Last update: 2024-09-29 04:37:05 UTC


README

Laravel 5.6 的 Gravatar 包

安装

要安装此包,请编辑项目的 composer.json 文件,并添加以下依赖:parsidev/gravatar5.0

"require": {
    "parsidev/gravatar": "5.6.x-dev"
},

现在,更新 Composer

composer update

Composer 完成后,您需要添加服务提供者。打开 config/app.php,并在 providers 数组中添加一个新条目。

'Parsidev\Gravatar\GravatarServiceProvider',

接下来,添加一个 Facade 以便更方便地使用。在 config/app.php 中,在 aliases 数组中添加以下行

'Gravatar'	=> 'Parsidev\Gravatar\Facades\Gravatar',

发布配置文件

php artisan vendor:publish

用法

Gravatar::exists($email)

返回一个布尔值,表示给定的 $email 是否有 Gravatar。

Gravatar::saveImage($email, $destination, $size=null, $rating=null)

下载 gravatar

Gravatar::src($email, $size = null, $rating = null)

Returns the https URL for the Gravatar of the email address specified. Can optionally pass in the size required as an integer. The size will be contained within a range between 1 - 512 as gravatar will no return sizes greater than 512 of less than 1

<!-- Show image with default dimensions -->
<img src="{{ Gravatar::src('info@parsidev.ir') }}">

<!-- Show image at 200px -->
<img src="{{ Gravatar::src('info@parsidev.ir', 200) }}">

<!-- Show image at 512px scaled in HTML to 1024px -->
<img src="{{ Gravatar::src('info@parsidev.ir', 1024) }}" width=1024>
Gravatar::image($email, $alt = null, $attributes = array(), $rating = null)

Returns the HTML for an <img> tag

echo Gravatar::image('info@parsidev.ir');

// Show image at 200px
echo Gravatar::image('info@parsidev.ir', 'Some picture', array('width' => 200, 'height' => 200));

// Show image at 512px scaled in HTML to 1024px
echo Gravatar::image('info@parsidev.ir', 'Some picture', array('width' => 1024, 'height' => 1024));