function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Profile Photo

I am creating a visualforce page which will display the profile photo of the user in it.

Can someone help me reference it ?

Ritesh AswaneyRitesh Aswaney

Select u.SmallPhotoUrl, u.FullPhotoUrl From User u


One of those should give you the URL to the Profile Pic of the User


In markup: 


<apex:page standardcontroller="user">
<apex:image value="{!User.smallphotourl}"/> <br/>
<apex:image value="{!User.fullphotourl}"/> <br/>


where you speciify the user id  in the query parameter for the page.   Obviously, variations where you get the id from somewhere else are more likely whay you want. 


Is this

<apex:image value="{$User.smallphotourl}"/>  ??


moreover I am already using a custom controller...

I need this photo on that same page...


I tried my suggestion (code pasted above)

it is not working..! :(


           When you will do Query to get User Profile photo by SOQL Query,FullPhotoUrl will provide




           This is sample code to retrieve profile photo url in a visual force page.


           VF code:

                              <apex:page controller="cls_PhotoUrl">


                                                 <apex:image value="{!Photolink}"/>




          Controller code:

                                               Public class cls_PhotoUrl


                                                   public string Photolink{get;set;}

                                                   Public cls_PhotoUrl()


                                                                 User u = [Select u.SmallPhotoUrl, u.FullPhotoUrl From User u where];

                                                                 Photolink = u.FullPhotoUrl;




I am making a public website using VisualForce


<apex:image url="{!DefaultUser.FullPhotoUrl}"  width="134" />

if user upload a image than image does not display on the page.


I have even try this using session. e.g.

<apex:image url="{!DefaultUser.FullPhotoUrl}?session_id={!$Api.Session_ID}&server_url={!$Api.Partner_Server_URL_140}"  width="134" />


Did you ever find a solution or workaround for this?  We're having the same issue - displaying a User Profile image works great when testing the VisualForce page, but on the "public" site - no luck. 


I'm also trying to solve this issue currently.  Did you find any solution or workaround?


In my implementation I have a "Team Bio" page which just lists the users from a particular Public Group.


Internally, the pics all show up fine, but on our Customer portal they do not.  I am convinced it is a session thing.


I would rather not have to duplicate all the images as document records or static resources.

Alex OhadiAlex Ohadi


Finally got it. 

Here it is with a custom controller embeded in a component. 

Component reference:

<apex:component Controller="profile">
    <apex:image id="profileImage" url="{!profileImageUrl}" />

Custom controller reference:

public class profile {
    public String profileImageUrl { get; set; }
    List<user> lstuser;
    public profile () {
         lstuser = [select FullPhotoUrl from User where Id =: UserInfo.getUserId()];

Apex code:

<apex:pageBlock >
               <apex:form >
                   <c:profile />



Alex O.


Ido Greenbaum 10Ido Greenbaum 10
Hi @Alex Ohadi, 
Thanks for providing this answer. 
Can you assist with the Test for the 'profile' class?