You are here

public function Gravatar::generateUri in Avatar Kit 8

Creates a URI to an avatar.

Parameters

\Drupal\Core\Session\AccountInterface $account: A user account.

Return value

string URI to an image file.

Overrides AvatarGeneratorBase::generateUri

File

avatars_gravatar/src/Plugin/AvatarGenerator/Gravatar.php, line 39

Class

Gravatar
Gravatar avatar generator.

Namespace

Drupal\avatars_gravatar\Plugin\AvatarGenerator

Code

public function generateUri(AccountInterface $account) {
  $gravatar = new GravatarAPI();
  if (!empty($this->configuration['maximum_rating'])) {
    $gravatar
      ->setRating($this->configuration['maximum_rating']);
  }
  return $gravatar
    ->setIdentifier($this
    ->getIdentifier($account))
    ->setType('gravatar')
    ->setFallbackType('404')
    ->setDimensions(256)
    ->getUrl();
}