Enterprise workspaces provide support for integrating user photos from an organization's repository, such as LDAP, in a number of user interfaces. For more information, see Configuring User Photo Support.
You can use the default photo service of enterprise workspaces to integrate user photos into your custom user interfaces or modules.
You can also implement a custom photo service to replace the default one. For more information, see Implementing a Custom User Photo Service.
The following example illustrates how to use a photo service, either default or custom, on the server side:
AbstractPhoto abstractPhoto = (AbstractPhoto) RuntimeFactory.getWorkspacesRuntime().getService(AbstractPhoto.class); String photoURL = abstractPhoto.getURL(iuser); // Pass the value to the client side response.write( "<script type=\"text/javascript\">" + "var photoURL = '" + photoURL + "';"; "</script>");
On the client side, be sure to handle null or invalid URL return values. In such cases, we recommend that you display a default avatar image instead of a photo.
For example:
var defaultPhotoURL = "/myapp/images/avatar.png"; var photo = $( "#someDivTagID" ).css("background-image", defaultPhotoURL); if( photoURL !== undefined ) { var img = new Image(); img.onload = function() { photo.css("background-image", "url(" + photoURL +")"); }; img.src = photoURL; }