Package hudson.tasks

Class UserAvatarResolver

  • All Implemented Interfaces:

    public abstract class UserAvatarResolver
    extends Object
    implements ExtensionPoint
    Infers avatar image URLs for users

    This is an extension point of Jenkins. Plugins that contribute a new implementation of this class should put Extension on your implementation class, like this:

     class MyUserAvatarResolver extends UserAvatarResolver {
    Erik Ramfelt
    • Constructor Detail

      • UserAvatarResolver

        public UserAvatarResolver()
    • 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.

        u - the user
        width - the preferred width of the avatar
        height - the preferred height of the avatar.
        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 use resolveOrNull(hudson.model.User, java.lang.String).
        u - user
        avatarSize - the preferred image size, "[width]x[height]"
        a URL string for a user Avatar image.