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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.