How to show profile photo in Visuaforce page?

Sample Code:

Visualforce page:

<apex:page controller="Sample">
    <apex:pageBlock >
        <apex:image value="{!photoURL}"/>
    </apex:pageBlock>
</apex:page>

Apex Controller:

public class Sample {
    public String photoURL {get;set;}

    public sample() {
        photoURL = [SELECT Id, smallPhotoURL FROM User WHERE ID =: UserInfo.getUserId()].smallPhotoURL;
    }


}

Output:



Cheers!!!

1 comment: