From d70f4e166dd9ce2f11a6ac2d7a2e500515657041 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:47:03 +0200 Subject: [feature/frontend] Allow setting alt-text for avatar + header (#3086) --- web/template/profile.tmpl | 86 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 9 deletions(-) (limited to 'web/template') diff --git a/web/template/profile.tmpl b/web/template/profile.tmpl index f0467e004..256bbdccf 100644 --- a/web/template/profile.tmpl +++ b/web/template/profile.tmpl @@ -35,6 +35,78 @@ {{- end }} {{- end -}} +{{- define "defaultAvatarDimension" -}} +{{- /* 136 is the default width/height for 8.5rem avatars, double it to get a good look when expanded. */ -}} +272 +{{- end -}} + +{{- define "avatarWidth" -}} +{{- with .account }} + {{- if isNil .AvatarAttachment -}} + {{- template "defaultAvatarDimension" . -}} + {{- else -}} + {{- /* Use the avatar's proper dimensions. */ -}} + {{- .AvatarAttachment.Meta.Original.Width -}} + {{- end -}} +{{- end }} +{{- end -}} + +{{- define "avatarHeight" -}} +{{- with .account }} + {{- if isNil .AvatarAttachment -}} + {{- template "defaultAvatarDimension" . -}} + {{- else -}} + {{- /* Use the avatar's proper dimensions. */ -}} + {{- .AvatarAttachment.Meta.Original.Height -}} + {{- end -}} +{{- end }} +{{- end -}} + +{{- define "avatarAlt" -}} + Avatar for {{ .account.Username -}} + {{- if .account.AvatarDescription }} + {{- /* Add the avatar's image description. */ -}} + : {{ .account.AvatarDescription -}} + {{- end -}} +{{- end -}} + +{{- define "headerAlt" -}} + Header for {{ .account.Username -}} + {{- if .account.HeaderDescription }} + {{- /* Add the header's image description. */ -}} + : {{ .account.HeaderDescription -}} + {{- end -}} +{{- end -}} + +{{- define "avatar" -}} +{{- with . }} + +{{- end }} +{{- end -}} + {{- with . }}

Profile for {{ .account.Username -}}

@@ -45,18 +117,14 @@
Header for {{ .account.Username -}}
- - Avatar for {{ .account.Username -}} - + {{- with . }} + {{- include "avatar" . | indent 3 }} + {{- end }}
Display name
-- cgit v1.2.3