diff --git a/src/IPub/Gravatar/Gravatar.php b/src/IPub/Gravatar/Gravatar.php index 2530174..5c4049c 100644 --- a/src/IPub/Gravatar/Gravatar.php +++ b/src/IPub/Gravatar/Gravatar.php @@ -59,11 +59,11 @@ final class Gravatar /** * The default image to use - * Either a string of the gravatar-recognized default image "type" to use, a URL, or FALSE if using the...default gravatar default image (hah) + * Either a string of the gravatar-recognized default image "type" to use, a URL, or NULL if using the...default gravatar default image (hah) * * @var mixed */ - private $defaultImage = FALSE; + private $defaultImage = NULL; /** * The maximum rating to allow for the avatar. @@ -200,7 +200,7 @@ public function setDefaultImage($image) : void { // Quick check against boolean FALSE. if ($image === FALSE) { - $this->defaultImage = FALSE; + $this->defaultImage = NULL; } else { // Check $image against recognized gravatar "defaults" @@ -442,11 +442,13 @@ private function createUrl(string $email, ?int $size = NULL, ?string $maxRating $size = $this->getSize(); } + $defaultImage = $this->getDefaultImage($defaultImage); + // Time to figure out our request params $params = [ 's' => $size, 'r' => $this->getMaxRating($maxRating), - 'd' => $this->getDefaultImage($defaultImage), + 'd' => $defaultImage === NULL ? FALSE : $defaultImage, 'f' => is_null($email) ? 'y' : NULL, ]; diff --git a/src/IPub/Gravatar/Latte/Macros.php b/src/IPub/Gravatar/Latte/Macros.php index 9e972f7..31b712f 100644 --- a/src/IPub/Gravatar/Latte/Macros.php +++ b/src/IPub/Gravatar/Latte/Macros.php @@ -69,7 +69,7 @@ public function macroGravatar(MacroNode $node, PhpWriter $writer) : string throw new Latte\CompileException('Please provide email address.'); } - return $writer->write('echo %escape(property_exists($this, "filters") ? call_user_func($this->filters->gravatar, ' . $arguments['email'] . ', ' . $arguments['size'] . ') : $template->getGravatarService()->buildUrl(' . $arguments['email'] . ', ' . $arguments['size'] . '));'); + return $writer->write('echo %escape(property_exists($this, "filters") ? call_user_func($this->filters->gravatar, ' . $arguments['email'] . ', ' . $arguments['size'] . ', ' . $arguments['maxRating'] . ', ' . $arguments['defaultImage'] . ') : $template->getGravatarService()->buildUrl(' . $arguments['email'] . ', ' . $arguments['size'] . ', ' . $arguments['maxRating'] . ', ' . $arguments['defaultImage'] . '));'); } @@ -89,7 +89,7 @@ public function macroAttrGravatar(MacroNode $node, PhpWriter $writer) : string throw new Latte\CompileException('Please provide email address.'); } - return $writer->write('?> ' . ($node->htmlNode->name === 'a' ? 'href' : 'src') . '="filters->gravatar, ' . $arguments['email'] . ', ' . $arguments['size'] . ') : $template->getGravatarService()->buildUrl(' . $arguments['email'] . ', ' . $arguments['size'] . '));?>" write('?> ' . ($node->htmlNode->name === 'a' ? 'href' : 'src') . '="filters->gravatar, ' . $arguments['email'] . ', ' . $arguments['size'] . ', ' . $arguments['maxRating'] . ', ' . $arguments['defaultImage'] . ') : $template->getGravatarService()->buildUrl(' . $arguments['email'] . ', ' . $arguments['size'] . ', ' . $arguments['maxRating'] . ', ' . $arguments['defaultImage'] . '));?>" $name, - 'size' => $size, + 'email' => $name, + 'size' => $size, + 'maxRating' => $maxRating, + 'defaultImage' => $defaultImage ]; } }