+ Start a Discussion

Problem showing User Image


I have a problem when override the user image. The image link change to something like this:


and before has v=1 .

I wonder where i can get the version number of the image or where this images are stored to check the size of the related images.

Thanks in advance,



In the beta release of Chatter the version number is unfortunately not available. One work around which I have used is to create a custom field, image_version__c on the User object which can be manually updated. You can then change your code to something like this:




It is not ideal as you still need to manually update the value on the user object but it does provide an interim solution.






I found another solution meanwhile they provide us a more elegant way to get the photo version. It's not the best one, but at least work and don't require manual changes.

This is the solution if you are interested:


List<User> users = [select id from Users];
String yourDomain = 'na7.salesforce.com';
Map<Id, String> userImages = new Map<Id, String>();
for (User iterUser : users) {
   PageReference pageRef = new PageReference('https://' + yourDomain + '/_ui/core/userprofile/UserProfilePage?u=' + iterUser.Id);
   String photoVersion = pageRef.getContent().toString();
   photoVersion = photoVersion .split('(?i)<div id="photoSection" class="photoSection">', 2)[1];
   photoVersion = photoVersion .split('(?i)&amp;s=', 2)[0];
   photoVersion = photoVersion .split('(?i)v=', 2)[1];
   String userImg = '<img src="/userphoto?id=' + iterUser.id + '&v=' + photoVersion + '&s=T" />';
   userImages.put(iterUser.id, userImg);