I have to disable a button if the profile photo is default (smiley) else if the photo is uploaded then the button should be enable in a visualforce page. I have a custom contrller and a visualforce page. Any help is appreciated.


After doing some this that I got this solution :

User usr = [SELECT usr.Id, usr.SmallPhotoUrl FROM User WHERE usr.Id =UserInfo.getUserId()

public void checkRemoveBtn()
         ConnectApi.ChatterUsers.deletePhoto(null, currentUser.Id);
         if(usr.SmallPhotoUrl =='/profilephoto/005/T')


Since in my situation, the default profile photo and uploaded photo both has been set through Static Resources. So before checking I'm deleting to get /profilephoto/005/T URL.


You can use the following SOQL to find the Users who has default profile picture.

List<User> u = [SELECT Id, FullPhotoUrl, SmallPhotoUrl FROM User WHERE 
        FullPhotoUrl = 'https://c.na20.content.force.com/profilephoto/005/F'];

You will get a list of users who has default profile picture. Iterate through the user list and disable the button using Apex. Make sure to get the correct link dynamically for your Org.

Eg : https://c.na20.content.force.com/profilephoto/005/F

Not the answer you're looking for? Browse other questions tagged or ask your own question.