Skip to content

Commit 4c21059

Browse files
authored
Merge pull request #4190 from Laravel-Backpack/removed-placeholder
Removed last bits of placeholder
2 parents f727bc6 + b1ab02e commit 4c21059

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

src/config/backpack/base.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,14 @@
268268
// What kind of avatar will you like to show to the user?
269269
// Default: gravatar (automatically use the gravatar for their email)
270270
// Other options:
271-
// - placehold (generic image with their first letter)
271+
// - null (generic image with their first letter)
272272
// - example_method_name (specify the method on the User model that returns the URL)
273273
'avatar_type' => 'gravatar',
274274

275+
// Gravatar fallback options are 'identicon', 'monsterid', 'wavatar', 'retro', 'robohash', 'blank'
276+
// 'blank' will keep the generic image with the user first letter
277+
'gravatar_fallback' => 'blank',
278+
275279
/*
276280
|--------------------------------------------------------------------------
277281
| Theme (User Interface)

src/helpers.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,12 @@ function backpack_users_have_email()
9696
*/
9797
function backpack_avatar_url($user)
9898
{
99-
$firstLetter = $user->getAttribute('name') ? mb_substr($user->name, 0, 1, 'UTF-8') : 'A';
100-
$placeholder = 'https://via.placeholder.com/160x160/00a65a/ffffff/&text='.$firstLetter;
101-
10299
switch (config('backpack.base.avatar_type')) {
103100
case 'gravatar':
104101
if (backpack_users_have_email()) {
105-
return Gravatar::fallback('https://via.placeholder.com/160x160/00a65a/ffffff/&text='.$firstLetter)->get($user->email);
106-
} else {
107-
return $placeholder;
102+
return Gravatar::fallback(config('backpack.base.gravatar_fallback'))->get($user->email);
108103
}
109104
break;
110-
111-
case 'placehold':
112-
return $placeholder;
113-
break;
114-
115105
default:
116106
return method_exists($user, config('backpack.base.avatar_type')) ? $user->{config('backpack.base.avatar_type')}() : $user->{config('backpack.base.avatar_type')};
117107
break;

src/resources/views/base/inc/menu_user_dropdown.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<li class="nav-item dropdown pr-4">
22
<a class="nav-link" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false" style="position: relative;width: 35px;height: 35px;margin: 0 10px;">
33
<img class="img-avatar" src="{{ backpack_avatar_url(backpack_auth()->user()) }}" alt="{{ backpack_auth()->user()->name }}" onerror="this.style.display='none'" style="margin: 0;position: absolute;left: 0;z-index: 1;">
4-
<span class="backpack-avatar-menu-container" style="position: absolute;left: 0;width: 100%;background-color: #00a65a;border-radius: 50%;color: #FFF;line-height: 35px;">
4+
<span class="backpack-avatar-menu-container" style="position: absolute;left: 0;width: 100%;background-color: #00a65a;border-radius: 50%;color: #FFF;line-height: 35px;font-size: 85%;font-weight: 300;">
55
{{backpack_user()->getAttribute('name') ? mb_substr(backpack_user()->name, 0, 1, 'UTF-8') : 'A'}}
66
</span>
77
</a>

0 commit comments

Comments
 (0)