I was looking for the best way to get a user profile picture with the Facebook Graph API.
Looking through the documentation, I've found this:
You can specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), normal (100 pixels wide, variable height), and large (about 200 pixels wide, variable height)
My question is: Is there any way to get the profile picture on a higher resolution than 200px?
I've recently found this solution, but I don't know how can I check if the user has the album in another language:
FB.api('/me/albums', function (response)
{
for (album in response.data)
{
// Find the Profile Picture album
if (response.data[album].name == "Profile Pictures")
{
// Get a list of all photos in that album.
FB.api(response.data[album].id + "/photos", function(response)
{
// The image link
image = response.data[0].images[0].source;
});
}
}
});
Pixels: The profile picture on Facebook has a pixel limitation that you might not be aware of. If your picture exceeds the pixel restriction, the picture is automatically adjusted and the quality will be reduced. Right format: The right image format is important to avoid the blurry end result.
This is straight from the documentation
You can specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), normal (100 pixels wide, variable height), and large (about 200 pixels wide, variable height):
http://graph.facebook.com/{ID}/picture?type=large
Now, there's nothing stopping you from calling into the graph to get larger sizes, but you have to have a valid user access token to do so.
You can control it by query string parameters by adding width and height: https://graph.facebook.com/1483610454/picture?width=160&height=160 https://graph.facebook.com/1483610454/picture?width=300&height=300
You can get the full quality image by using the Facebook JavaScript API:
FB.api('/{ID}?fields=picture.height(2048)', function(response){
$("#profile_pic").attr("src",response.picture.data.url);
});
Assuming you have a
<img id="profile_pic" src=""/>
Somewhere in the body
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With