CI / validate-monitoring (push) Successful in 10s
CI / lint (push) Successful in 14s
CI / federation-interop (push) Successful in 1m15s
CI / test (push) Successful in 7m2s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / trigger-deploy (push) Skipped
CI / notify (push) Successful in 5s
A Profile page to upload, use Gravatar or remove the image, the avatar in the page header and on the public profile, a Sharing switch for it, and user/admin guide notes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
20 lines
796 B
JavaScript
20 lines
796 B
JavaScript
// A round profile image that starts as a placeholder ring and swaps itself for the real
|
|
// picture once (if) it loads. `source` is either a signed-in user (their own image,
|
|
// fetched with their token) or { path } for another public image URL.
|
|
|
|
import { fetchImage } from "./api.js";
|
|
import { h } from "./dom.js";
|
|
|
|
export function avatarImage(user, extraClass, path = "/me/avatar") {
|
|
const classes = extraClass ? `avatar ${extraClass}` : "avatar";
|
|
const el = h("span", { class: `${classes} avatar-empty`, "aria-hidden": "true" });
|
|
if (!user?.has_avatar) return el;
|
|
fetchImage(path).then((url) => {
|
|
if (!url) return; // miss or failed fetch: leave the placeholder
|
|
const img = h("img", { class: classes, alt: "" });
|
|
img.src = url;
|
|
el.replaceWith(img);
|
|
});
|
|
return el;
|
|
}
|