create default profile image

This commit is contained in:
Dennis Eichhorn 2021-08-06 19:29:11 +02:00
parent 4c28981f1f
commit 08d382cfce
5 changed files with 79 additions and 64 deletions

View File

@ -77,6 +77,11 @@ final class BackendController extends Controller
$view->setData('accounts', ProfileMapper::getAfterPivot(0, null, 25)); $view->setData('accounts', ProfileMapper::getAfterPivot(0, null, 25));
} }
$profileImage = $this->app->appSettings->get(null, 'default_profile_image', 'Profile');
$image = MediaMapper::get((int) $profileImage['content']);
$view->setData('defaultImage', $image);
return $view; return $view;
} }
@ -122,6 +127,11 @@ final class BackendController extends Controller
$media = MediaMapper::getFor((int) $profile->account->getId(), 'createdBy'); $media = MediaMapper::getFor((int) $profile->account->getId(), 'createdBy');
$view->setData('media', $media instanceof NullMedia ? [] : (!\is_array($media) ? [$media] : $media)); $view->setData('media', $media instanceof NullMedia ? [] : (!\is_array($media) ? [$media] : $media));
$profileImage = $this->app->appSettings->get(null, 'default_profile_image', 'Profile');
$image = MediaMapper::get((int) $profileImage['content']);
$view->setData('defaultImage', $image);
return $view; return $view;
} }

View File

@ -1,3 +1,4 @@
<div>
<div class="ipt-wrap wf-100"> <div class="ipt-wrap wf-100">
<div class="ipt-first"> <div class="ipt-first">
<span class="input"> <span class="input">
@ -52,3 +53,4 @@
</span> </span>
</template> </template>
</div> </div>
</div>

View File

@ -57,14 +57,16 @@ $next = empty($accounts) ? '{/prefix}profile/list' : '{/prefix}profile/list?
<i class="filter fa fa-filter"></i> <i class="filter fa fa-filter"></i>
</label> </label>
<tbody> <tbody>
<?php $count = 0; foreach ($accounts as $key => $account) : ++$count; <?php $count = 0;
$url = UriFactory::build('{/prefix}profile/single?{?}&id=' . $account->getId()); ?> foreach ($accounts as $key => $account) : ++$count;
$url = UriFactory::build('{/prefix}profile/single?{?}&id=' . $account->getId());
?>
<tr tabindex="0" data-href="<?= $url; ?>"> <tr tabindex="0" data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="profile-image" <td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="profile-image"
src="<?= src="<?=
$account->image instanceof NullMedia ? $account->image instanceof NullMedia
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') : ? UriFactory::build('{/prefix}' . $this->getData('defaultImage')->getPath())
UriFactory::build('{/prefix}' . $account->image->getPath()); ?>"></a> : UriFactory::build('{/prefix}' . $account->image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->name3 . ' ' . $account->account->name2 . ' ' . $account->account->name1); ?></a> <td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->name3 . ' ' . $account->account->name2 . ' ' . $account->account->name1); ?></a>
<td data-label="<?= $this->getHtml('Activity'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->getLastActive()->format('Y-m-d')); ?></a> <td data-label="<?= $this->getHtml('Activity'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->getLastActive()->format('Y-m-d')); ?></a>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -71,9 +71,9 @@ echo $this->getData('nav')->render();
alt="<?= $this->getHtml('ProfileImage'); ?>" alt="<?= $this->getHtml('ProfileImage'); ?>"
itemprop="logo" loading="lazy" itemprop="logo" loading="lazy"
src="<?= src="<?=
$profile->image instanceof NullMedia ? $profile->image instanceof NullMedia
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') : ? UriFactory::build('{/prefix}' . $this->getData('defaultImage')->getPath())
UriFactory::build('{/prefix}' . $profile->image->getPath()); ?>" : UriFactory::build('{/prefix}' . $profile->image->getPath()); ?>"
width="100px"></div> width="100px"></div>
<?php if ($this->request->header->account === $account->getId()) : ?> <?php if ($this->request->header->account === $account->getId()) : ?>
<div><a id="iProfileUploadButton" href="#upload" data-action='[ <div><a id="iProfileUploadButton" href="#upload" data-action='[

View File

@ -18,12 +18,13 @@
"directory": "Profile", "directory": "Profile",
"dependencies": { "dependencies": {
"Admin": "1.0.0", "Admin": "1.0.0",
"Media": "1.0.0",
"Home": "1.0.0", "Home": "1.0.0",
"Contact": "1.0.0", "Contact": "1.0.0"
"Media": "1.0.0"
}, },
"providing": { "providing": {
"Navigation": "*" "Navigation": "*",
"Media": "1.0.0"
}, },
"load": [ "load": [
{ {