2017 © Pedro Peláez
 

library ogravatar

Simple class that provides easy gravatar integration.

image

masnathan/ogravatar

Simple class that provides easy gravatar integration.

  • Thursday, October 3, 2013
  • by MASNathan
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

oGravatar ReiDuKuduro @gittip

Simple class that provides easy gravatar integration, (*1)

Getting the avatar

First you need to create a oGravatar object, see below:, (*2)

$my_gravatar = new oGravatar('andre.r.flip@gmail.com');

If you want to use a secure connection, you'll need to pass true as second parameter., (*3)

Now that you have the object created, you can set the some properties like the image size, rating and a default image, in case of a non Gravatar account., (*4)

Image Size

Simply use the setSize function and use an integer greater than 1 and less than 2048 for the pixel size., (*5)

$my_gravatar->setSize(200);

Image Rating

The function you need is setRating and you can use one of the following constants to simplify your life:, (*6)

  • oGravatar::RATING_G
  • oGravatar::RATING_PG
  • oGravatar::RATING_R
  • oGravatar::RATING_X

Just like this:, (*7)

$my_gravatar->setRating(oGravatar::RATING_X);

Default Image

As you can imagine, my creativity isn't that great, I called this function setDefault, you can either set the image path, that you want to define as default, or use one of the following constants:, (*8)

  • oGravatar::DEFAULT_404
  • oGravatar::DEFAULT_MM
  • oGravatar::DEFAULT_IDENTICON
  • oGravatar::DEFAULT_MONSTERID
  • oGravatar::DEFAULT_WAVATAR

Well, you know…, (*9)

$my_gravatar->setDefault(oGravatar::DEFAULT_MONSTERID);

It's avatar time!!

Now that you know how to set some properties, you can get the image, to get the URL., (*10)

$my_gravatar->getAvatarUrl();
//http://en.gravatar.com/avatar/c34fd2d73a25fabf0bf9ef8f85dbae42?s=200&r=x&d=monsterid

If you dont want to loose time writing the HTML, you can do it this way:, (*11)

$attributes = array(
    'id'    => 'my_gravatar_image',
    'class' => 'some_random_class or-not',
    'style' => 'height: 200px',
    'width' => '200px'
);
$my_gravatar->getAvatar($attibutes);
//<img src="http://en.gravatar.com/avatar/c34fd2d73a25fabf0bf9ef8f85dbae42?s=200&r=x&d=monsterid"  id="my_gravatar_image"  class="some_random_class or-not"  style="height: 200px"  width="200px"  />

Getting the profile info

If you want to request the profile info simply call $my_gravatar->getProfile();, once you do that, you can check if they email you are using has a profile by doing something like this:, (*12)

if ($my_gravatar->has_profile) {
    echo '<pre>';
    print_r($my_gravatar);
    echo '</pre>';
} else {
    echo "This email doesn't have a gravatar account";
}

But wait there is more…

… you can chain the functions, watch it:, (*13)

echo $my_gravatar->setSize(200)
                 ->setRating(oGravatar::RATING_X)
                 ->setDefault(oGravatar::DEFAULT_MONSTERID)
                 ->getAvatar($attributes);

The Versions

03/10 2013

dev-master

9999999-dev https://github.com/ReiDuKuduro/oGravatar

Simple class that provides easy gravatar integration.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

profile image gravatar

03/10 2013

0.1.0

0.1.0.0 https://github.com/ReiDuKuduro/oGravatar

Simple class that provides easy gravatar integration.

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

profile image gravatar