Gravatar
Gravatar Image
If a customer has registered their email with a Gravatar, you can display that image within your frontend code using the helpers from the Kart plugin.
<?php
$user = kirby()->user();
$gravatarUrl = $user->gravatar(200); // in pixel
if ($gravatarUrl) { ?>
<img src="<?= $gravatarUrl ?>" alt="<?= $user->name() ?>">
<?php } else { ?>
<span><?= $user->initials() ?></span>
<?php } ?>
The data blob from the URL of the image is cached for 24 hours to avoid slowing down your frontend. It also fetches the data serverside to avoid having external URLs within your frontend.