How to get logged in user image in SharePoint 2013 (MySite)

$.ajax({
     url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager"+
      "/GetMyProperties?$select=PictureUrl,DisplayName,AccountName",
     type: "GET",
     contentType: "application/json;odata=verbose",
     headers: { "accept": "application/json;odata=verbose" },
     async: false,
     success: function (data) {
             var pic = data.d.PictureUrl;
             var member = data.d.DisplayName;
             if (pic) {
                  $("#userName").text(member);
                  $("#paduserName").text(member);
                  $(".imageicon").attr("src",pic.Url);
            }
            else {
                 $("#userName").text(member);
                 $("#paduserName").text(member);
                 $(".imageicon").attr("src", "/SiteAssets/profile-icon.png")
            }
      }, 
      error: function (jqxr, errorCode, errorThrown) {
           console.log(jqxr.responseText);
      }
});
Advertisements
This entry was posted in Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

3 Responses to How to get logged in user image in SharePoint 2013 (MySite)

  1. Alex says:

    Great blog right here! Additionally your website a lot up fast! What web host are you using? Can I get your affiliate hyperlink to your host? I wish my website loaded up as quickly as yours lol

  2. Alex says:

    I’m not certain where you’re getting your info, however great topic. I must spend some time learning more or working out more. Thanks for excellent info I used to be on the lookout for this info for my mission.

  3. Cherie Hampton says:

    Thank you, I’ve just been looking for info about this topic for ages and yours is the greatest I’ve came upon till now. But, what about the bottom line? Are you positive about the supply?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s