Im using Laravel 5.2 with Socialite. I am able to pull out the details of the user but the problem is that the avatar is not being displayed properly if I inject it on its src
.
Socialite returns an object wherein I could use it as $facebookDetails->getAvatar()
in which returns a value of like this https://graph.facebook.com/v2.6/123456789/picture?type=normal
If I echo this value in the image src
, it would look like this.
<img src="https://graph.facebook.com/v2.6/123456789/picture?type=normal" />
It seems that this is not the actual URL of the image since when I enter this on the browser, it redirects me to the "actual" image and displays the image.
How could I display the image on the img
tag to display the actual image?
Simply fetch the data using file_get_contents
function and process the retrieved data.
In Controller
use File;
$fileContents = file_get_contents($user->getAvatar());
File::put(public_path() . '/uploads/profile/' . $user->getId() . ".jpg", $fileContents);
//To show picture
$picture = public_path('uploads/profile/' . $user->getId() . ".jpg");
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