Package hudson.tasks
Class UserAvatarResolver
- java.lang.Object
-
- hudson.tasks.UserAvatarResolver
-
- All Implemented Interfaces:
ExtensionPoint
public abstract class UserAvatarResolver extends Object implements ExtensionPoint
Infers avatar image URLs for usersThis is an extension point of Jenkins. Plugins that contribute a new implementation of this class should put
Extension
on your implementation class, like this:@Extension class MyUserAvatarResolver extends
UserAvatarResolver
{ ... }- Since:
- 1.434
- Author:
- Erik Ramfelt
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Constructor Summary
Constructors Constructor Description UserAvatarResolver()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static ExtensionList<UserAvatarResolver>
all()
Returns all the registeredUserAvatarResolver
descriptors.abstract String
findAvatarFor(User u, int width, int height)
Finds an avatar image URL string for a user.static String
resolve(User u, String avatarSize)
Resolve an avatar image URL string for the user.static String
resolveOrNull(User u, String avatarSize)
Likeresolve(hudson.model.User, java.lang.String)
but returns null rather than a fallback URL in case there is no special avatar.
-
-
-
Method Detail
-
findAvatarFor
public abstract String findAvatarFor(User u, int width, int height)
Finds an avatar image URL string for a user.This method is called when a web page is going to show an avatar for a
User
.When multiple resolvers are installed, they are consulted in order and the search will be over when an avatar is found by someone.
Since
UserAvatarResolver
is singleton, this method can be invoked concurrently from multiple threads.- Parameters:
u
- the userwidth
- the preferred width of the avatarheight
- the preferred height of the avatar.- Returns:
- null if the inference failed.
-
resolve
public static String resolve(User u, String avatarSize)
Resolve an avatar image URL string for the user. Note that this method must be called from an HTTP request to be reliable; else useresolveOrNull(hudson.model.User, java.lang.String)
.- Parameters:
u
- useravatarSize
- the preferred image size, "[width]x[height]"- Returns:
- a URL string for a user Avatar image.
-
resolveOrNull
@CheckForNull public static String resolveOrNull(User u, String avatarSize)
Likeresolve(hudson.model.User, java.lang.String)
but returns null rather than a fallback URL in case there is no special avatar.- Since:
- 1.518
-
all
public static ExtensionList<UserAvatarResolver> all()
Returns all the registeredUserAvatarResolver
descriptors.
-
-