mirror of
https://github.com/flarum/core.git
synced 2025-08-06 00:17:31 +02:00
perf: add loading="lazy"
attribute for avatars (#3578)
Co-authored-by: David Wheatley <david@davwheat.dev>
This commit is contained in:
@@ -12,6 +12,7 @@ export interface AvatarAttrs extends ComponentAttrs {}
|
||||
*/
|
||||
export default function avatar(user: User | null, attrs: ComponentAttrs = {}): Mithril.Vnode {
|
||||
attrs.className = 'Avatar ' + (attrs.className || '');
|
||||
attrs.loading ??= 'lazy';
|
||||
let content: string = '';
|
||||
|
||||
// If the `title` attribute is set to null or false, we don't want to give the
|
||||
|
@@ -41,7 +41,7 @@ export default class AvatarEditor extends Component {
|
||||
|
||||
return (
|
||||
<div className={classList(['AvatarEditor', 'Dropdown', this.attrs.className, this.loading && 'loading', this.isDraggedOver && 'dragover'])}>
|
||||
{avatar(user)}
|
||||
{avatar(user, { loading: 'eager' })}
|
||||
<a
|
||||
className={user.avatarUrl() ? 'Dropdown-toggle' : 'Dropdown-toggle AvatarEditor--noAvatar'}
|
||||
title={app.translator.trans('core.forum.user.avatar_upload_tooltip')}
|
||||
|
@@ -54,7 +54,7 @@ export default class UserCard extends Component {
|
||||
[AvatarEditor.component({ user, className: 'UserCard-avatar' }), username(user)]
|
||||
) : (
|
||||
<Link href={app.route.user(user)}>
|
||||
<div className="UserCard-avatar">{avatar(user)}</div>
|
||||
<div className="UserCard-avatar">{avatar(user, { loading: 'eager' })}</div>
|
||||
{username(user)}
|
||||
</Link>
|
||||
)}
|
||||
|
Reference in New Issue
Block a user