Skip to content

Commit

Permalink
fix(Widgets/UserList): Ensure individual profile photos look for all …
Browse files Browse the repository at this point in the history
…the same photo extensions that the full users List does.
  • Loading branch information
Patrick Mulligan committed May 13, 2024
1 parent 3256cc0 commit 6824300
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/Widgets/UserList/UserList.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function run()
{
$segments = request()->segments();
$last = end($segments);
$photoExtensions = ['jpg', 'jpeg', 'png'];

if ($last)
{
Expand All @@ -35,10 +36,13 @@ public function run()
$user->phone = $user->facet('phone');
$user->bio = $user->facet('bio');
$user->thumb = asset('files/staff_thumb.png');

if (file_exists(storage_path('app/public/users/' . $user->username . '/photo.jpg')))
foreach ($photoExtensions as $ext)
{
$user->thumb = asset('files/users/' . $user->username . '/photo.jpg');
if (file_exists(storage_path('app/public/users/' . $user->username . '/photo.' . $ext)))
{
$user->thumb = asset('files/users/' . $user->username . '/photo.' . $ext);
break;
}
}

return view($this->getViewName('profile'), [
Expand Down Expand Up @@ -162,7 +166,7 @@ public function run()
$dir = 'users/' . $user->username;
}

foreach (['jpg', 'jpeg', 'png'] as $ext)
foreach ($photoExtensions as $ext)
{
if (file_exists(storage_path('app/public/' . $dir . '/photo.' . $ext)))
{
Expand Down

0 comments on commit 6824300

Please sign in to comment.