@Override
    public Element loadVCard(String username) {
        // Un-escape username.
        username = JID.unescapeNode(username);
        Map<String, String> map = getLdapAttributes(username);
        Log.debug("LdapVCardProvider: Getting mapped vcard for " + username);
        Element vcard = new VCard(template).getVCard(map);
        // If we have a vcard from ldap, but it doesn't have an avatar filled in, then we
        // may fill it with a locally stored vcard element.
        if (dbStorageEnabled && vcard != null && (vcard.element("PHOTO") == null || vcard.element("PHOTO").element("BINVAL") == null || vcard.element("PHOTO").element("BINVAL").getText().matches("\\s*"))) {
            Element avatarElement = loadAvatarFromDatabase(username);
            if (avatarElement != null) {
                Log.debug("LdapVCardProvider: Adding avatar element from local storage");
                vcard.elements("PHOTO").forEach(vcard::remove);
                vcard.add(avatarElement);
            }
        }

        if ( JiveGlobals.getBooleanProperty( PhotoResizer.PROPERTY_RESIZE_ON_LOAD, PhotoResizer.PROPERTY_RESIZE_ON_LOAD_DEFAULT ) )
        {
            PhotoResizer.resizeAvatar( vcard );
        }

        Log.debug("LdapVCardProvider: Returning vcard");
        return vcard;
    }
Loads the avatar from LDAP, based off the vcard template.

If enabled, will replace a blank PHOTO element with one from a DB stored vcard.

@param username User we are loading the vcard for.
@return The loaded vcard element, or null if none found.
xmppserver/src/main/java/org/jivesoftware/openfire/ldap/LdapVCardProvider.java