In my current Confluence wiki project, I need to show the profile picture for the current user in the header of every page. This will help in a couple of ways:
- It gives the wiki a more human touch
- The wiki will be used in an environment where many of the people will be sharing computers, the user photo will allow them to quickly see who they are currently logged on as
I’ve googled and googled on this one, and I can’t find any current macros to do it. Bubbles, the community and social network plugin from Adaptavist, will have a macro for exactly this, but is currently in a closed beta… and I don’t need any other Bubbles functionality for this project.
After a bit of wrestling with the Confluence technical documentation and my first very basic Velocity markup language efforts, I’ve got something working, note that this will only work on pages (i.e. not in settings pages, etc). Copy and paste the code below into a new User Macro (Confluence > Administration Console > User Macros > Create a user macro) :
#set( $profile_pic = $userAccessor.getUserProfilePicture( $req.userPrincipal.name ) )
#set( $pic_src = $profile_pic.getDownloadPath() )
<a href="/users/editmyprofilepicture.action" title="Upload a different profile picture"><img src="$pic_src" alt="Your profile picture" border="0" /></a>
The macro code above links the profile picture directly to a page where the user can upload or change their user profile picture. If you don’t want the picture to be linked, use the code below instead:
#set( $profile_pic = $userAccessor.getUserProfilePicture( $req.userPrincipal.name ) )
#set( $pic_src = $profile_pic.getDownloadPath() )
<img src="$pic_src" alt="Your profile picture" />
Put “user_profile_pic” in the Macro name field, then untick “Macro has a body”, and set the drop down to “Macro generates HTML markup”. You can then include the macro in your Confluence page, or Adaptavist Theme Builder panel, with the macro code below:
{user_profile_pic}
Next task: make this into an easily distributable plugin that people can simply upload into their Confluence installation.
Leave a Reply to Simon Cancel reply