I'm using SharePoint Online and I'm trying to retrieve user photo making a request to userphoto.aspx
with this URL:
var account = encodeURI(user@domain.tld);
return "https://mysharepoint.sharepoint.com/_layouts/15/userphoto.aspx?size=L&accountname="+account;
For some users this is working fine and I see the image correctly, for others it keeps returning the image like it is missing (but I checked and user added its own user photo).
The user who I am checking has never opened the company SharePoint site.
Any idea?