Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Is there an example of a custom avatar component? I'm trying to use the oauth2 user image.

default discord avatar
supakulast year

I'm using the oauth2 plugin to authenticate a Google account for my users. I would like to take their existing profile picture and use it as their avatar by default.



From what I've read here and grok'd from the source, I will need to create a custom avatar component. Is there an example of such a component?



Also, should I take the URL image, download it, and re-upload it into a media collection for purpose of the user avatar?



Thank you 🙏



took inspiration from the gravatar implementation and arrived at this:



import React from 'react';
import { useAuth } from 'payload/components/utilities';

const GoogleAvatar: React.FC = () => {
    const { user } = useAuth();
    return (
    <img
    className="google-avatar"
    style={{ borderRadius: '50%' }}
    src={String(user.picture)}
    alt="yas"
    width={25}
    height={25}
    />
);
};

export default GoogleAvatar;
    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.