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
bensondanielbensondaniel 

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

aballardaballard

In markup: 

 

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

 

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. 

bensondanielbensondaniel

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..! :(

Pradeep_NavatarPradeep_Navatar

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

 

           "https://c.ap1.content.force.com/profilephoto/72990000000PD3X/F."

 

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

 

           VF code:

                              <apex:page controller="cls_PhotoUrl">

                                                 <apex:form>

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

                                                 </apex:form>

                                   </apex:page>

 

          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 u.id=:Userinfo.getUserid()];

                                                                 Photolink = u.FullPhotoUrl;

                                                   }

                                                }

leo.shoaibleo.shoaib

I am making a public website using VisualForce

e.g.

<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" />

MarkWill94MarkWill94

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. 

DownstairsBDownstairsB

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

Wassup.

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}" />
</apex:component>


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()];
         profileImageUrl=lstuser[0].FullPhotoUrl; 
    }
}


Apex code:

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




------------------------


Welcome,

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?