Profilbilder: Avatar-Upload, Anzeige auf Profil & Feed
- user.avatar-Spalte (Schema, migrate.sh, Migrationsdoku)
- POST /user/avatar (geschützt): Upload via storeImage, ersetzt/löscht altes Bild
- avatar in /u/{name}/info, /user/info und im entrySelect-Join (Feed-Karten)
- Account-Löschung entfernt auch das Avatar-File
- Frontend: Avatar im Profilkopf + Byline der Karten (50px), Upload-Form,
Platzhalterbild no_profile_pic.jpg als Fallback
- .card img per :not(.avatar) von Beitragsbildern getrennt
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,20 @@ document.getElementById("rename-form").addEventListener("submit", async (e) => {
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("avatar-form").addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
const res = await api.post("/user/avatar", new FormData(e.target));
|
||||
if (res.ok) {
|
||||
// Cache umgehen, damit das neue Bild sofort erscheint.
|
||||
document.getElementById("profile-avatar").src = `${avatarUrl(res.data.avatar)}?t=${Date.now()}`;
|
||||
e.target.reset();
|
||||
document.getElementById("avatar-msg").textContent = "";
|
||||
} else {
|
||||
document.getElementById("avatar-msg").textContent =
|
||||
res.data.error || "Hochladen fehlgeschlagen.";
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById("delete-form").addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (!confirm("Konto wirklich unwiderruflich löschen?")) return;
|
||||
@@ -34,6 +48,7 @@ async function init() {
|
||||
}
|
||||
|
||||
document.getElementById("profile-name").textContent = info.username;
|
||||
document.getElementById("profile-avatar").src = avatarUrl(info.avatar);
|
||||
const since = new Date(info.created_at * 1000).toLocaleDateString("de-DE");
|
||||
document.getElementById("profile-info").textContent = `Mitglied seit ${since}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user