Replace Filament's default avatar url provider with one for Gravatar.
First, install the plugin with composer.
composer require awcodes/filament-gravatar
Next, add the GravatarProvider
to your panel.
use Awcodes\FilamentGravatar\GravatarProvider;Â public function panel(Panel $panel): Panel{ return $panel ->defaultAvatarProvider(GravatarProvider::class) ->plugins([ GravatarPlugin::make(), ])}
You can modify the global defaults by using the following methods on the GravatarPlugin
.
public function panel(Panel $panel): Panel{ return $panel ->plugins([ GravatarPlugin::make() ->default('robohash') ->size(200) ->rating('pg'), ])}
You can also use the Awcodes\FilamentGravatar\Gravatar
class by itself should you need to outside a panel.
Awcodes\FilamentGravatar\Gravatar::get( string $email = null, int $size = 80, string $default = 'mp', string $rating = 'g', bool $asImage = false, array $attributes = []);
Adam is a full-stack web developer (with a focus on Laravel) who has been coding for close to 20 years. He is a core Filament team member as well and has authored numerous plugins for Filament such as Curator, Tiptap Editor and Table Repeater, to name a few. You can learn more about Adam on his website.