feat: fallback avatar

This commit is contained in:
Baoshuo Ren 2023-02-07 19:36:48 +08:00
parent 6202e1a74f
commit e626faf2ab
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
8 changed files with 14 additions and 8 deletions

View File

@ -170,7 +170,7 @@ $pag = new Paginator($pag_config);
<div class="mb-3">
<span class="me-2 d-inline-block">
<a class="text-decoration-none" href="<?= HTML::url('/user/' . $poster['username']) ?>">
<img src="<?= HTML::avatar_addr($poster, 64) ?>" width="32" height="32" class="rounded" />
<img src="<?= HTML::avatar_addr($poster, 64) ?>" width="32" height="32" class="rounded uoj-user-avatar" />
</a>
<?= UOJUser::getLink($poster) ?>
</span>

View File

@ -263,7 +263,7 @@ $comments_pag = new Paginator([
<div class="d-flex">
<div class="mr-3 flex-shrink-0">
<a href="<?= HTML::url('/user/' . $poster['username']) ?>" class="d-none d-sm-block text-decoration-none">
<img class="rounded" src="<?= $asrc ?>" alt="Avatar of <?= $poster['username'] ?>" width="64" height="64" />
<img class="rounded uoj-user-avatar" src="<?= $asrc ?>" alt="Avatar of <?= $poster['username'] ?>" width="64" height="64" />
</a>
</div>
<div id="comment-body-<?= $comment['id'] ?>" class="flex-grow-1 ms-3">

View File

@ -32,7 +32,7 @@ $all_tags = DB::selectAll("select distinct tag from blogs_tags where blog_id in
<?= $blogs_pag->pagination() ?>
</div>
<div class="col-lg-3">
<img class="media-object img-thumbnail center-block" alt="<?= UOJUserBlog::id() ?> Avatar" src="<?= HTML::avatar_addr(UOJUserBlog::user(), 512) ?>" />
<img class="media-object img-thumbnail center-block uoj-user-avatar" alt="<?= UOJUserBlog::id() ?> Avatar" src="<?= HTML::avatar_addr(UOJUserBlog::user(), 512) ?>" />
<?php if (UOJUserBlog::userCanManage(Auth::user()) && UOJUser::checkPermission(Auth::user(), 'blogs.create')) : ?>
<div class="btn-group d-flex mt-3">
<a href="<?= HTML::blog_url(UOJUserBlog::id(), '/post/new/write') ?>" class="btn btn-primary">

View File

@ -256,7 +256,7 @@ if (isset($_POST['user_msg'])) {
'<div class="list-group-item list-group-item-action p-2 d-flex ' + (type ? 'list-group-item-warning' : '') + '" style="cursor: pointer; user-select: none;" ' +
'onclick="enterConversation(\'' + conversationName + '\')">' +
'<div class="flex-shrink-0 me-3">' +
'<img class="rounded" width="56" height="56" src="' + avatar_addr + '" />' +
'<img class="rounded uoj-user-avatar" width="56" height="56" src="' + avatar_addr + '" />' +
'</div>' +
'<div class="flex-grow-1 overflow-hidden">' +
'<div class="d-flex justify-content-between">' +
@ -290,7 +290,7 @@ if (isset($_POST['user_msg'])) {
'<span class="float-end" data-bs-toggle="tooltip" data-bs-title="' + read_time + '"><i class="bi bi-check2-all"></i></span>') +
'</div>' +
'</div>' +
(type ? '<img class="flex-shrink-0 ms-2 rounded" width="32" height="32" src="' + user_avatar + '" style="user-select: none;" />' : '') +
(type ? '<img class="flex-shrink-0 ms-2 rounded uoj-user-avatar" width="32" height="32" src="' + user_avatar + '" style="user-select: none;" />' : '') +
'</div>'
);
}

View File

@ -54,7 +54,7 @@ class UOJRanklist {
<div class="list-group-item">
<div class="d-flex">
<div class="flex-shrink-0">
<a href="{$userpro}"><img class="rounded" src="{$asrc}" width="50" height="50" /></a>
<a href="{$userpro}"><img class="rounded uoj-user-avatar" src="{$asrc}" width="50" height="50" /></a>
</div>
<div class="flex-grow-1 ms-3">
<div class="row">

View File

@ -3,7 +3,7 @@
<div class="container">
<a class="navbar-brand" href="<?= HTML::blog_url(UOJUserBlog::id(), '/') ?>">
<img src="<?= HTML::avatar_addr(UOJUserBlog::user(), 48) ?>" alt="Logo" width="24" height="24" class="d-inline-block align-text-top" />
<img src="<?= HTML::avatar_addr(UOJUserBlog::user(), 48) ?>" alt="Logo" width="24" height="24" class="d-inline-block align-text-top uoj-user-avatar" />
<?= UOJUserBlog::id() ?>
</a>

View File

@ -3,7 +3,7 @@
<div class="row">
<div class="col-md-3">
<div class="card">
<img class="card-img-top" alt="Avatar of <?= $user['username'] ?>" src="<?= HTML::avatar_addr($user, 512) ?>" />
<img class="card-img-top uoj-user-avatar" alt="Avatar of <?= $user['username'] ?>" src="<?= HTML::avatar_addr($user, 512) ?>" />
<div class="card-body">
<?php if ($user['usergroup'] == 'S') : ?>
<span class="badge bg-secondary">

View File

@ -1772,3 +1772,9 @@ $(document).ready(function() {
);
});
});
$(document).ready(function() {
$('img.uoj-user-avatar').on('error', function() {
$(this).attr('src', 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4NzIgODcyIj48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMCAwaDg3MnY4NzJIMHoiLz48cGF0aCBmaWxsPSIjYzVjNWM1IiBkPSJNMCAwdjg3MmgxMTBhMzI3IDM4MyAwIDAxMjM2LTM0NSAxOTUgMTk1IDAgMDEtMTA0LTE3MiAxOTUgMTk1IDAgMDExOTUtMTk1IDE5NSAxOTUgMCAwMTE5NSAxOTUgMTk1IDE5NSAwIDAxLTEwNiAxNzMgMzI3IDM4MyAwIDAxMjM2IDM0NGgxMTBWMHoiLz48L3N2Zz4=');
});
});