PHP code example of artdarek / gravatarer

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

    

artdarek / gravatarer example snippets


'providers' => array(
	'Artdarek\Gravatarer\GravatarerServiceProvider'
),


	// user email
	$email = "[email protected]";

	// create a gravatar object for specified email
 	$gravatar = Gravatarer::user( $email );

	 // get gravatar url as a string
	$url = $gravatar->url();



	// user email
	$email = "[email protected]";

	// create a gravatar object for specified email with additional settings
 	$gravatar = Gravatarer::user( $email );

 	// Size in pixels, defaults to 80px [ 1 - 2048 ]
	$gravatar->size('220');

	// Maximum rating (inclusive) [ g | pg | r | x ]
	// defaults to 'g'
	$gravatar->rating('g');

	// Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
	// You can also specify url to your own default avatar image
	// defaults to 'mm'
	$gravatar->defaultImage('mm');

    // set gravatarer to build urls with https [true = use https, false = ise http]
    // defaults to 'false'
    $gravatar->secured( true );

	// get gravatar url as a string
	$url = $gravatar->url();



 	$url = Gravatarer::user( $email )->size('220')->rating('g')->defaultImage('mm')->url();


	// user email
	$email = "[email protected]";

	// create a gravatar object for specified email
 	$gravatar = Gravatarer::make( $email );

	 // get gravatar url as a string
	$url = $gravatar->url();



	// to get url string
	$url = Gravatarer::make( $email )->url();


	// user email
	$email = "[email protected]";

	// create a gravatar object in specified size
 	$url = Gravatarer::make( ['email' => $email, 'size' => 220] )->url();

	// create a gravatar object with some other additional parameters
 	$url = Gravatarer::make( [
 		'email' => $email,
 		'size' => 220,
 		'defaultImage' => 'mm',
 		'rating' => 'g',
 	    'secured' => true
 	])->url();


	// user email
	$email = "[email protected]";

	// create some gravatarer object
 	$gravatar = Gravatarer::user( $email )->size('120');

	 // get gravatar <img> html code
	$html = $gravatar->html();


	$html = Gravatarer::user( $email )->html( ['class' => 'avatar', 'id' => 'user123' ] );