Yii 1.1: gravatar

Add Gravatar avatars support to your applications.
10 followers

This extension allows you to display a Gravatar in your view files. Full documented and customizable.

Resources

Documentation

Installation Instructions:

  1. Download the extension
  2. Unzip the file contents
  3. Upload the VGGravatarWidget.php file to the extensions folder located under WebRoot/protected/extensions
  4. Read Usage Instructions.

Requirements:

This should work on all Yii versions (That has widgets working in them), But was tested on version 1.0.9 & 1.1.x .

Usage:

Inside your view file just paste the following code:

<?php
$this->widget('application.extensions.VGGravatarWidget', 
                                                            array(
                                                                  'email' => 'myemail@mydomain.com', // email to display the gravatar belonging to it
                                                                  'hashed' => false, // if the email provided above is already md5 hashed then set this property to true, defaults to false
                                                                  'default' => 'http://www.mysite.com/default_gravatar_image.jpg', // if an email is not associated with a gravatar this image will be displayed,
                                                                                                                                   // by default this is omitted so the Blue Gravatar icon will be displayed you can also set this to
                                                                                                                                   // "identicon" "monsterid" and "wavatar" which are default gravatar icons
                                                                  'size' => 50, // the gravatar icon size in px defaults to 40
                                                                  'rating' => 'PG', // the Gravatar ratings, Can be G, PG, R, X, Defaults to G
                                                                  'htmlOptions' => array( 'alt' => 'Gravatar Icon' ), // Html options that will be appended to the image tag
                                                            ));
?>

Change Log

March 31, 2010

  • Initial release.

Total 3 comments

#4639 report it
scribbly at 2011/07/28 10:31am
failed to open stream: Permission denied ??

Why am I getting an error:

require(G:\xamp\htdocs\test_ug\protected\extensions\VGGravatarWidget.php) [<a href='function.require'>function.require</a>]: failed to open stream: Permission denied

G:\xamp\htdocs\yii\YiiBase.php(319)

#529 report it
Jack Fiallos at 2010/05/04 06:06pm
Extending gravatar plg

I added a new protected variable for redirect to some url

protected $redirect = '';

and run method add this

if (!empty($this->redirect)) echo CHtml::link(CHtml::image(self::GRAVATAR_URL . $this->url, $this->htmlOptions['alt'], $this->htmlOptions), $this->redirect); else echo CHtml::image(self::GRAVATAR_URL . $this->url, $this->htmlOptions['alt'], $this->htmlOptions);

#643 report it
Junior - df9 at 2010/03/31 06:11am
Good Job!!

It will certainly save me some time!!

Thanks!!

:)

Leave a comment

Please to leave your comment.

Create extension