Class cebe\gravatar\Gravatar

Inheritancecebe\gravatar\Gravatar » yii\base\Widget

Displays a gravatar image tag.

To use this widget, you may insert the following code in a view:

echo \cebe\gravatar\Gravatar::widget([
    'email' => 'mail@cebe.cc',
    'size' => 128,
    'defaultImage' => 'monsterid',
//  'secure' => false, // will be autodetected
    'rating' => 'r',
    'options'=>[
        'alt'=>'Gravatar image',
        'title'=>'Gravatar image',
    ]
]);
</pre>

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$defaultImage string Default image to use if no gravatar available cebe\gravatar\Gravatar
$email string The email to use cebe\gravatar\Gravatar
$fileType string Can be 'png' or 'jpg' cebe\gravatar\Gravatar
$gravatarUrl cebe\gravatar\Gravatar
$gravatarUrlSecure cebe\gravatar\Gravatar
$options array Html options for the image tag cebe\gravatar\Gravatar
$rating string Gravatar image rating cebe\gravatar\Gravatar
$secure boolean Whether to use $gravatarUrl or $gravatarUrlSecure as base url. cebe\gravatar\Gravatar
$size int Image size in pixel cebe\gravatar\Gravatar

Public Methods

Hide inherited methods

MethodDescriptionDefined By
getEmailHash() Generates email hash for gravatar url cebe\gravatar\Gravatar
getImageUrl() cebe\gravatar\Gravatar
run() cebe\gravatar\Gravatar
setEmailHash() Sets the email hash to use for gravatar url cebe\gravatar\Gravatar

Property Details

$defaultImage public property

Default image to use if no gravatar available

public string $defaultImage null
$email public property

The email to use

public string $email null
$fileType public property

Can be 'png' or 'jpg'

public string $fileType null
$gravatarUrl public property
public $gravatarUrl 'http://www.gravatar.com/avatar/'
$gravatarUrlSecure public property
public $gravatarUrlSecure 'https://secure.gravatar.com/avatar/'
$options public property

Html options for the image tag

public array $options = []
$rating public property

Gravatar image rating

public string $rating 'g'
$secure public property

Whether to use $gravatarUrl or $gravatarUrlSecure as base url. If not set it will be detected by current request.

public boolean $secure null
$size public property

Image size in pixel

public int $size 128

Method Details

getEmailHash() public method

Generates email hash for gravatar url

public string getEmailHash ( )
return string

Md5 hash of the trimmed lowercase $email

throws \yii\base\InvalidConfigException

if no email has been specified.

getImageUrl() public method

public string getImageUrl ( )
return string

Generates the gravatar image url

run() public method

public void run ( )
setEmailHash() public method

Sets the email hash to use for gravatar url

public void setEmailHash ( $hash )
$hash