1

Using SharepointOnline. I got pictures url in the form of

https://domain-my.sharepoint.com/User%20Photos/Profile%20Pictures/username_domain_onmicrosoft_com_MThumb.jpg";

I insert them into img src attribute on my sharepoint site, but it showing default gray user picture in Google Chrome and it shows photo only for my account. In Firefox i got my account picture and for another one account. In IE i just not checked.

Tried the SP.ExecutorRequest:

var hostweburl = "https://domain.sharepoint.com";
var appweburl = "https://domain-my.sharepoint.com";
function execCrossDomainRequest() {
var context;
var factory;
var appContextSite;

context = new SP.ClientContext(appweburl);
factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
context.set_webRequestExecutorFactory(factory);
appContextSite = new SP.AppContextSite(context, hostweburl);

var executor = new SP.RequestExecutor(appweburl);

executor.executeAsync(
    {
        url:
            appweburl +
                "/User%20Photos/Profile%20Pictures/username_domain_onmicrosoft_com_MThumb.jpg",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: successHandler,
        error: errorHandler
    }
);
}
function successHandler(data) {
   debugger;
}

function errorHandler(data, errorCode, errorMessage) {
   debugger;
}

Ran it in chrome's console and got myself in errorHandler with errorCode=-1007. So i tried the way from another question: Enable Cross-Domain Profile Photos in SharePoint Online Got the same result: almost working in Chrome and FF and not working in IE11. I want to make it work in IE and Google Chrome, please help.

0

I dont have fix to your issue, but will tell a workaround we have implemented. I have faced a similar kind of issue in one of my project, while trying to display user profile picture using SPServices, it was working in chrome and FF but not in FF. The issue was due to cross-site publishing feature, I guess the configuration for cross-site publishing has to be done in Farm/Web application level, which is not accepted as it will affect entire farm. So, we decided to create a user control (.ascx) which will programatically fetch the user profile picture and display it. We have added the user control to Master page so that it is visble in all the pages. Just try it.

0

Found a workaround using a separate custom list with 2 columns: "Photo" and "User". That is no CORS happening and the script just get photo urls from list by comparing the user's id from the column "User".

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.