From 02bc23c832d82cf94fc5377ff566989dfa3e7bdf Mon Sep 17 00:00:00 2001 From: Julian Prieber Date: Wed, 8 Mar 2023 22:03:54 +0100 Subject: [PATCH] Avatar type findAvatar() --- app/Functions/findfile.php | 11 +++++++++++ resources/views/littlelink.blade.php | 6 ++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Functions/findfile.php b/app/Functions/findfile.php index 9517f55..bd4fcc7 100644 --- a/app/Functions/findfile.php +++ b/app/Functions/findfile.php @@ -11,6 +11,17 @@ function findFile($name){ return $pathinfo; } +function findAvatar($name){ + $directory = base_path('/img'); + $files = scandir($directory); + $pathinfo = "error.error"; + foreach($files as $file) { + if (strpos($file, $name.'.') !== false) { + $pathinfo = "/img/" . $name. "." . pathinfo($file, PATHINFO_EXTENSION); + }} + return $pathinfo; +} + function findBackground($name){ $directory = base_path('/img/background-img/'); $files = scandir($directory); diff --git a/resources/views/littlelink.blade.php b/resources/views/littlelink.blade.php index 91df5c3..90645a8 100644 --- a/resources/views/littlelink.blade.php +++ b/resources/views/littlelink.blade.php @@ -283,10 +283,8 @@ function get_operating_system() {
- @if(file_exists(base_path("img/" . $userinfo->id . ".png"))) - avatarid . ".png") }}" width="128px" height="128px" style="object-fit: cover;"> - @elseif(file_exists(base_path("littlelink/images/").findFile('avatar'))) - avatar + @if(file_exists(base_path(findAvatar($userinfo->id)))) + avatar @else avatar @endif