Avatar type findAvatar()

This commit is contained in:
Julian Prieber 2023-03-08 22:03:54 +01:00
parent 19ddd37182
commit 02bc23c832
2 changed files with 13 additions and 4 deletions

View File

@ -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);

View File

@ -283,10 +283,8 @@ function get_operating_system() {
<div class="row">
<div class="column" style="margin-top: 5%">
<!-- Your Image Here -->
@if(file_exists(base_path("img/" . $userinfo->id . ".png")))
<img alt="avatar" class="rounded-avatar fadein" src="{{ asset("img/" . $userinfo->id . ".png") }}" width="128px" height="128px" style="object-fit: cover;">
@elseif(file_exists(base_path("littlelink/images/").findFile('avatar')))
<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;">
@if(file_exists(base_path(findAvatar($userinfo->id))))
<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;">
@else
<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;">
@endif