1. Go to this page and download the library: Download phalcon/incubator-avatar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phalcon / incubator-avatar example snippets
use Phalcon\Incubator\Avatar\Gravatar;
$di->setShared(
'gravatar',
function () {
// Get Gravatar instance
$gravatar = new Gravatar(
[]
);
// Setting default image, maximum size and maximum allowed Gravatar rating
$gravatar->setDefaultImage('retro')
->setSize(220)
->setRating(Gravatar::RATING_PG);
return $gravatar;
}
);
use Phalcon\Incubator\Avatar\Gravatar;
// Config must be either an array or \Phalcon\Config instance
$config = [
'default_image' => 'mm',
'rating' => 'x',
'size' => 110,
'use_https' => true,
];
$di->setShared(
'gravatar',
function () use ($config) {
// Get Gravatar instance
$gravatar = new Gravatar($config);
return $gravatar;
}
);
// Get the Gravatar service from DI
$gravatar = $this->getDi()->getShared('gravatar');
// Build the Gravatar URL based on the configuration and provided email address
echo $gravatar->getAvatar('[email protected]');
// Set gravatars size 64x64px
$gravatar->setSize(64);
// Set gravatars size 100x100px
$gravatar->setSize('100');
// boolean false for the gravatar default
$gravatar->setDefaultImage(false);
// string specifying a recognized gravatar "default"
$gravatar->setDefaultImage('identicon');
// string with image URL
$gravatar->setDefaultImage('http://example.com/your-default-image.png');