Skip to content

Commit 02bc23c

Browse files
committed
Avatar type findAvatar()
1 parent 19ddd37 commit 02bc23c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

app/Functions/findfile.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ function findFile($name){
1111
return $pathinfo;
1212
}
1313

14+
function findAvatar($name){
15+
$directory = base_path('/img');
16+
$files = scandir($directory);
17+
$pathinfo = "error.error";
18+
foreach($files as $file) {
19+
if (strpos($file, $name.'.') !== false) {
20+
$pathinfo = "/img/" . $name. "." . pathinfo($file, PATHINFO_EXTENSION);
21+
}}
22+
return $pathinfo;
23+
}
24+
1425
function findBackground($name){
1526
$directory = base_path('/img/background-img/');
1627
$files = scandir($directory);

resources/views/littlelink.blade.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,8 @@ function get_operating_system() {
283283
<div class="row">
284284
<div class="column" style="margin-top: 5%">
285285
<!-- Your Image Here -->
286-
@if(file_exists(base_path("img/" . $userinfo->id . ".png")))
287-
<img alt="avatar" class="rounded-avatar fadein" src="{{ asset("img/" . $userinfo->id . ".png") }}" width="128px" height="128px" style="object-fit: cover;">
288-
@elseif(file_exists(base_path("littlelink/images/").findFile('avatar')))
289-
<img alt="avatar" class="rounded-avatar fadein" src="{{ asset('littlelink/images/'.findFile('avatar')) }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}" width="128px" height="128px" style="object-fit: cover;">
286+
@if(file_exists(base_path(findAvatar($userinfo->id))))
287+
<img alt="avatar" class="rounded-avatar fadein" src="{{ url(findAvatar($userinfo->id)) }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}" width="128px" height="128px" style="object-fit: cover;">
290288
@else
291289
<img alt="avatar" class="rounded-avatar fadein" src="{{ asset('littlelink/images/logo.svg') }}" srcset="{{ asset('littlelink/images/avatar@2x.png 2x') }}" width="128px" height="128px" style="object-fit: cover;">
292290
@endif

0 commit comments

Comments
 (0)