PHP code example of pespantelis / gravatar

1. Go to this page and download the library: Download pespantelis/gravatar 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/ */

    

pespantelis / gravatar example snippets




// vendor/autoload.php';

// set options (optional)
$options = [
  'size' => 256,
  'default-image' => 'identicon',
  'force-default' => false,
  'rating' => 'pg',
  'secure' => true
];

$gravatar = new Peslis\Gravatar\Factory($options);

echo $gravatar->url('[email protected]');

echo $gravatar->exists('[email protected]');
// or
echo $gravatar->url('[email protected]')->exists();

// size
echo $gravatar->url('[email protected]', 256);
// or
echo $gravatar->url('[email protected]')->size(256);

// secure requests
echo $gravatar->url('[email protected]')->secure();

// default image
echo $gravatar->url('[email protected]')->defaultImage('identicon');

// force default image
echo $gravatar->url('[email protected]')->forceDefault();

// rating level
echo $gravatar->url('[email protected]')->rating('pg');

echo $gravatar->url('[email protected]', 256)->defaultImage('identicon')->rating('pg');