Connecting image field to image stored in database

Hi, I want to write a code to get a user’s image after he/she logs in to the site in an image field.
The image should either be from google/fb account or from the image that the person uploads in my database after logging in.

Please note i have created a custom login using this piece of code :

import wixUsers from ‘wix-users’;
import wixData from ‘wix-data’;
import wixLocation from ‘wix-location’;

$w.onReady( () => {
if(wixUsers.currentUser.loggedIn) {
$w(“#button6”).label = “Logout”;
$w(“#button7”).show();
$w(“#image8”).show();
}
else {
$w(“#button6”).label = “Login”;
$w(“#button7”).hide();
$w(“#image8”).hide();
}
} );

export function button6_onclick(event, $w) {
// user is logged in
if(wixUsers.currentUser.loggedIn) {
// log the user out
wixUsers.logout()
.then( () => {
// update buttons accordingly
$w(“#button6”).label = “Login”;
$w(“#button7”).hide();
$w(“#image8”).hide();

 } ); 

}
// user is logged out
else {
let userId;
let userEmail;
// prompt the user to log in
wixUsers.promptLogin( {“mode”: “login”} )
.then( (user) => {
userId = user.id;
return user.getEmail();
} )
.then( (email) => {
// check if there is an item for the user in the collection
userEmail = email;
return wixData.query(“Member”)
.eq(“_id”, userId)
.find();
} )
.then( (results) => {
// if an item for the user is not found
if (results.items.length === 0) {
// create an item
const toInsert = {
“_id”: userId,
“email”: userEmail
};
// add the item to the collection
wixData.insert(“Member”, toInsert)
.catch( (err) => {
console.log(err);
} );
}
// update buttons accordingly
$w(“#button6”).label = “Logout”;
$w(“#button7”).show();
$w(“#image8”).show();

  } ) 
  .catch( (err) => { 
    console.log(err); 
  } ); 

}
}

export function button7_onclick(event, $w) {
//Add your code for this event here:
wixLocation.to(/Member/Update/${wixUsers.currentUser.id});
}

1 Like