Inserting a profile image into a Sitecore contact is very simple (if it is given to you by a user or user is logged on via Facebook or other social networks). On a simple example, I’ll show you how to add an image to the visitor’s Profile so that we can see the contact’s photo in the details of the contact.

img-contact-exp-profile-final

var contactRepository = new ContactRepository();
var contact = Tracker.Current.Contact;
var pictureFacet = contact.GetFacet<IContactPicture>("Picture");
if (pictureFacet.IsEmpty)
{
    var imageUrl = "facebookImageUrl";
    var webClient = new WebClient();
    // Download data from URL
    byte[] imageBytes = webClient.DownloadData(imageUrl);
    if (imageBytes != null)
    {
        pictureFacet.Picture = imageBytes;
        pictureFacet.MimeType = "image/jpeg";
    }
}
var options = new ContactSaveOptions(true, null);
contactRepository.SaveContact(contact, options);

When you call this code, photo from the specified URL is saved to the active user on the web.