Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How Do I Insert a User Avatar into a VM plugin file

Jackson Farnsworth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2018

Hey all,

I'm trying to add an avatar using the AUI described here, but it still requires a link to the image. Is there a particular way to get a user's avatar image file location? Or is there a particular way for displaying it?

Thanks for any help you can provide

2 answers

1 accepted

0 votes
Answer accepted
Jackson Farnsworth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 6, 2018

Using Gravatar API in a JavaServlet

Get user email hash:

public String gravatarHash(ApplicationUser user) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] digested = md.digest(user.getEmailAddress().toLowerCase().getBytes());

StringBuilder buff = new StringBuilder();
for (byte b : digested) {
String conversion = Integer.toString(b & 0xFF,16);
while (conversion.length() < 2) {
conversion = "0" + conversion;
}
buff.append(conversion);
}
return buff.toString();

} catch (NoSuchAlgorithmException ex) {
log.error("No Such Algorithm Exception, passing empty string for user: " + user.getName());
return "";
}
}

 

 Then insert hash into vm file (example assumes $gravatarHash is the above hash)

#avatar {
background-image
: url(https://www.gravatar.com/avatar/$gravatarHash?d=mm&s=24);
width: 24px;
height: 24px;
}

The "d=mm" provides the default user white silhouette on grey background if no gravatar is associated with the user.
The "s=24" provides the image in 24x24 px size 

 

Hopefully someone else can make use of this info

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 31, 2018

Hi Jackson,

While the AUI guide might help with explaining the styles, I don't think it provides enough information on the specific syntax need, particular for when you have this image in a plugin.  I would recommend taking a look at

https://developer.atlassian.com/server/jira/platform/web-resource/

as well as

https://developer.atlassian.com/server/jira/platform/downloadable-add-on-resources/

The differences here are also explained in the first document:

JIRA plugins may define downloadable resources. If your plugin requires JIRA to serve additional static Javascript or CSS files, you will need to use downloadable web resources to make them available. Web resources differ from Downloadable Plugin Resources in that web resources are added at the top of the page in the header.

I hope this is helpful.

Andy

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events