Skip to content

Commit 27fcd45

Browse files
committed
fixed gravatar layout to work without email
1 parent 3ca84bc commit 27fcd45

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/views/layouts/gravatar.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010

1111
use cebe\gravatar\Gravatar;
1212

13-
echo Gravatar::widget([
14-
'email' => empty($email) ? Yii::$app->user->identity->email : $email,
15-
'defaultImage' => 'identicon',
13+
if (empty($email)) {
14+
$email = Yii::$app->user->identity->email;
15+
}
16+
17+
echo Gravatar::widget(array_filter([
18+
'email' => $email,
19+
'emailHash' => empty($email) ? md5('') : null,
20+
'defaultImage' => empty($email) ? null : 'identicon',
1621
'options' => [
1722
'alt' => empty($alt) ? Yii::$app->user->identity->username : $alt,
1823
'class' => empty($class) ? 'img-circle' : $class,
1924
],
2025
'size' => empty($size) ? 25 : $size,
21-
]);
26+
]));

0 commit comments

Comments
 (0)