Gravatar

Gravatar Image

If a member has registered their email with a Gravatar, you can display that image within your frontend code using the helpers from the Klub plugin.

<?php
    $user = kirby()->user();
    $gravatarUrl = $user->gravatar();

    if ($gravatarUrl) { ?>
    <img src="<?= $gravatarUrl ?>" alt="<?= $user->name() ?>">
<?php } else { ?>
    <span><?= $user->initials() ?></span>
<?php } ?>
The URL to the image is cached for 60 minutes to avoid slowing down your frontend.
Kirby Klub is not affiliated with the developers of Kirby CMS. We are merely standing on the shoulder of giants.
© 2024 Bruno Meilick All rights reserved.