useravatar

Last modified by Lucas Charpentier on 2026/10/27 10:30

Audit

Macro ID
useravatar
Source
XS
Type
Generator
Classification reason
The macro has no content: its whole output is the avatar picture of the user given by its username parameter, read from the user profile, so it is classified as a generator.
Status
Reviewed
Criteria version
15.20
XWiki version
18.8.0
Audit date
2026-10-19
Auditor
Compared macros
displayIcon chart

Sources

Where to gather the information the criteria are checked against, see Gather the sources.

SourceWhat it givesUsed forWhere
DocumentationParameters, default values and examples, including the most common exampleL2, L3, and the criteria measured with the most common examplehttps://extensions.xwiki.org/xwiki/bin/view/Extension/User%20Avatar%20Macro#HUsage
Source codeHow the macro declares its parameters and content: types, groups, features, advanced and hidden flags, constraints, content type, inline supportC4, C5, C7, C8, C9, C13, E4, E6https://github.com/xwiki/xwiki-platform/blob/xwiki-platform-18.8.0/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-useravatar/src/main/java/org/xwiki/rendering/internal/macro/useravatar/UserAvatarMacro.java
Macro descriptorWhat the Edit Macro dialog is built from, on design.xwiki.orgD1, D2, C1 to C9, E4Descriptor, list of macros with their categories
TranslationsThe name, description and parameter names in each languageD1, D2, D4, C1l10n.xwiki.org
Uses in XWiki pagesHow XWiki itself uses the macro, a realistic example when the documentation has noneL3, C2, C3, C6, C8, C9Search the xwiki organization on GitHub
Compared macrosThe audits of the macros of the same typeL1, D3displayIcon, chart
Other sources specific to this macro
CriterionResultNotes
D1 wordingOK"User Avatar" is the user's word for the picture of a user's profile.
D2 summaryKO"Allows displaying the avatar for a specific user." mostly repeats the name "User Avatar", behind the filler "Allows displaying". It does not say that the picture comes from the user profile, nor that a default picture is shown when the user has none.
D3 categoryOKContent, like the compared macros displayIcon and chart.
D4 quick-actionKO"User Avatar", "useravatar" and "avatar" give the macro first, and so does the French name "Afficher la photo de profil". The synonyms "photo", "picture", "profile", "portrait", "profile picture" and "user picture" give no result, and "user" gives it 8th, after User Mention and the Notifications preferences macros.
L1 consistencyOKcompared with displayIcon and chart, two generators of the Content category with no content. Like them, the macro has a mandatory parameter, the user, so Quick Actions and the Insert Macro dialog open the Edit Macro dialog. Unlike chart, which declares and shows its default width and height, the macro declares no size, so the avatar shows at the size of the uploaded picture: the difference is counted under C3 of width and height.
L2 doc-parametersKOthe parameters are only documented on the legacy extensions.xwiki.org page, not in the new documentation. That page also gives "image's natural width" as the default of height and "The width of the avatar image" as its description, and calls the avatar "a url that is defined by editing a user's profile", while it is an attachment of the profile.
L3 doc-exampleOKthe documentation gives the most common use, the avatar of a user at a small size, {{useravatar username="XWiki.JohnDoe" width="40" height="40"/}} , introduced as "The avatar of some XWiki.JohnDoe user". It renders without error once that user exists, the setup step the documentation states; on a wiki without that user it gives "User [XWiki.JohnDoe] is not registered in this wiki". The first block, {{useravatar username="<username>" /}} , is a template, not an example.
I1 patternOKcompared with children, the reference generator, and displayIcon. From the Insert Macro dialog and from the Quick Actions entry "User Avatar", the Edit Macro dialog opens, since the username is mandatory, the generic behavior seen for displayIcon and id.
I2 zero-configOKsubmitting the Edit Macro dialog with the empty mandatory username keeps the dialog open with no message, the generic behavior of the dialog. {{useravatar/}} typed in the source gives "Invalid macro parameters used for the [useravatar] macro. Cause: [Property [username] mandatory]." in view mode, acceptable for a generator that needs its user.
I3 instantN/A
I4 cursorN/A
I5 focusOKthe mandatory Username field comes first, visible without scrolling, and has the focus when the dialog opens.
E1 wysiwygOK {{useravatar username="XWiki.JohnDoe" width="40" height="40"/}} , for a test user with an uploaded avatar, shows the same 40 by 40 picture in the editor and in view mode. A user with no avatar, like Admin, shows the default noavatar.png in both.
E2 errorsKOinvalid sizes are accepted silently. {{useravatar username="XWiki.JohnDoe" width="abc"/}} , width="50%" and width="40px" render the image with width="0", so the avatar disappears with no message, and height="abc" or height="50%" does the same with height="0". width="-5" and height="-5" are output as is. A username that is not a user, {{useravatar username="Main.WebHome"/}} , silently gives the default avatar. An unknown user, {{useravatar username="XWiki.NoSuchUser"/}} , or the display name username="John Doe" gives "User [XWiki.NoSuchUser] is not registered in this wiki", which says what is wrong but not which parameter, and an empty username="" gives the same message with the name of the current page as user.
E3 nestingOKin a list item, a table cell and a box, {{useravatar username="XWiki.JohnDoe" width="40" height="40"/}} renders its picture with no error, inline in the list item and the table cell, and can be edited through its dialog as at the top level.
E4 inline-supportOKthe macro declares inline support and renders inside a sentence, as an inline image with no block element.
E5 emptyN/A
E6 inplaceN/A

Parameters

ParameterC1 clarityC2 mandatoryC3 defaultsC4 input-assistanceC5 groupsC6 orderC7 alternativesC8 advancedC9 technicalC13 constraintsNotes
heightKOOKKOKOOKOKN/AOKOKKO

C1, minor: "The image's height" does not give the unit, pixels, nor that an empty value keeps the height of the uploaded picture. The English name is the parameter ID "height", which the dialog shows capitalized.

C3, minor: the field opens empty, which stands for the height of the uploaded picture, a value the dialog does not show and that depends on each user's upload: an avatar of 300 by 200 pixels shows at that size. Every use sets a size, 40 in the documentation examples and a width of 100 in the release sheet of XWiki Standard, but no single value is used in most cases.

C4: a plain text field for a number of pixels.

C6: Height comes first in the Optional parameters tab, both are set in the most common example.

C8: not marked as advanced, and set in the most common example.

C9: set in the documentation examples.

C13: a number, typed Integer, with no declared range, while only a positive number of pixels makes sense: height="abc" or height="50%" can be typed in the text field and is rendered as height="0", and height="-5" is output as is, see E2.

usernameOKOKN/AOKOKOKN/AOKOKN/A

C1: "The name of the user whose avatar is to be displayed" says what to give. The English name is the parameter ID "username", which the dialog shows capitalized as "Username".

C2: mandatory with no default, which is right: the user is the whole purpose of the macro.

C4: a user picker. Searching "John", "Doe" or "johndoe" lists John Doe with their avatar, "Adm" lists Administrator, and picking a user writes username="XWiki.JohnDoe" . Opening the dialog of an existing macro shows the selected user.

C5: three fields, Username outside any group and Height and Width in the Optional parameters tab.

C6: Username, set in the most common example, comes first.

C13: N/A, the accepted values are the users of the wiki, picked from a list.

widthKOOKKOKOOKOKN/AOKOKKO

C1, minor: "The image's width" does not give the unit, pixels, nor that an empty value keeps the width of the uploaded picture. The English name is the parameter ID "width", which the dialog shows capitalized.

C3, minor: the field opens empty, which stands for the width of the uploaded picture, a value the dialog does not show and that depends on each user's upload: an avatar of 300 by 200 pixels shows at that size. Every use sets a size, 40 in the documentation examples and a width of 100 in the release sheet of XWiki Standard, but no single value is used in most cases.

C4: a plain text field for a number of pixels.

C6: Width comes after Height in the Optional parameters tab, since neither declares an order: both are set in the most common example and only two fields are in the tab, so it is easy to reach. The only use in XWiki pages, the release sheet, sets width only.

C8: not marked as advanced, and set in the most common example.

C9: set in the documentation examples.

C13: a number, typed Integer, with no declared range, while only a positive number of pixels makes sense: width="abc" , width="50%" or width="40px" can be typed in the text field and is rendered as width="0", and width="-5" is output as is, see E2.

Other notes

The image gets the English alt text "Picture of JohnDoe" in every UI language, built from the page name of the user rather than their display name "John Doe", and the title "JohnDoe". Setting both width and height, as the documentation example does, stretches an avatar that is not square. Bugs outside the criteria, to file in JIRA.

KOs and tickets

Every KO needs a ticket covering it, see Report the KOs. One ticket can cover several KOs. Known issues filed for this macro are suggested in italics: link them as existing tickets when they cover the KO.

KOCriterionExisting ticketsNew tickets
D2D2 summaryXWIKI-25487
D4D4 quick-actionXWIKI-25444
L2L2 doc-parametersXINFRA-525
E2E2 errorsXCOMMONS-3847 (partial), XRENDERING-823 (partial), XWIKI-25583 (partial)
C1:heightC1 clarity, heightXWIKI-25487
C3:heightC3 defaults, heightXWIKI-25488
C4:heightC4 input-assistance, heightXWIKI-25182
C13:heightC13 constraints, heightXWIKI-25182
C1:widthC1 clarity, widthXWIKI-25487
C3:widthC3 defaults, widthXWIKI-25488
C4:widthC4 input-assistance, widthXWIKI-25182
C13:widthC13 constraints, widthXWIKI-25182
Success

Every KO is covered by a ticket.

Tickets

TicketOriginKOs coveredKOs partly covered
XWIKI-25182ExistingC13:height C13:width C4:width C4:height
XCOMMONS-3847NewE2
XRENDERING-823NewE2
XWIKI-25444NewD4
XWIKI-25487NewC1:height C1:width D2
XWIKI-25488NewC3:height C3:width
XINFRA-525NewL2
XWIKI-25583NewE2

Known issues of this macro

No known issue is specific to this macro.
68 more known issues affect every macro: see the Known issues.

Get Connected