I have a google login system on my web page, here user login data store into the database but I have some problem to set profile picture size in Google login. In Codeigniter How can I set custom profile picture size.
I am trying with these code:
<?php if ($client->getAccessToken()) { $gpInfo = $objOAuthService->userinfo->get(); $_SESSION['access_token'] = $client->getAccessToken(); } else { $authUrl = $client->createAuthUrl(); redirect($authUrl); } $userData['picture_url'] = !empty($gpInfo['picture'])?$gpInfo['picture']:''; ?>
In codeigniter upload user profile image and save to database using PHP MYSQLI with custom size profile picture. You need to put profile picture size after picture URL. Use “?sz=size value” after getting user picture user, for example:
<?php $picture_url = !empty($gpInfo['picture'])?$gpInfo['picture']:''; // Set picture url in a variable $userData['picture_url'] = $picture_url.'?sz=300'; // sz=300 it use for set profile picture size ?>
If you login with this process the your profile picture URL presented like to
https://lh5.googleusercontent.com/-z9KiX-sbp5c/AAAAAAAAAAI/AAAAAAAAAAA/_9GzJlfHXxM/photo.jpg?sz=300
You can copy your picture URL and enter it in URL and change the picture size value and get appropriate profile size.
Question and answer is powered by AnsPress.io