-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added get_gravatar function and README file
- Loading branch information
1 parent
82173ad
commit ea6df9c
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
Gravatar Helper Spark for CodeIgniter | ||
============================ | ||
|
||
[Gravatar](http://gravatar.com) Helper functions to utilize with [CodeIgniter](http://codeigniter.com) 2.x and 3.x or Standard PHP Application. | ||
|
||
|
||
Usage | ||
------------------------------------- | ||
|
||
1. Copy `gravatar_helper.php` to your `application/helpers` folder. | ||
2. Autoload the helper in `application/config/autoload.php`: $autoload['helper'] = array('gravatar'); | ||
3. Use helper functions as needed. | ||
|
||
|
||
Examples | ||
------------------------------------- | ||
|
||
/** | ||
* Get either a Gravatar URL or complete image tag for a specified email address. | ||
* | ||
* @param string $email The email address | ||
* @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ] | ||
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] | ||
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ] | ||
* @param bool $img True to return a complete IMG tag False for just the URL | ||
* @param array $atts Optional, additional key/value attributes to include in the IMG tag | ||
* @return String containing either just a URL or a complete image tag | ||
*/ | ||
|
||
<?php echo gravatar( '[email protected]', 180 )?> | ||
|
||
|
||
License | ||
------------------------------------- | ||
|
||
© 2016 Omkar Tapale. All Rights Reserved. | ||
|
||
Released under the MIT License: [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
defined('BASEPATH') OR exit('No direct script access allowed'); | ||
|
||
/** | ||
* CodeIgniter Gravatar Helper | ||
* | ||
* Gravatar Helper functions to utilize with Codeigniter 2.x and 3.x | ||
* or Standard PHP Application. | ||
* | ||
* @package CodeIgniter Gravatar | ||
* @subpackage Helpers | ||
* @category Helpers | ||
* @author Omkar Tapale | ||
* @copyright 2016 Omkar Tapale | ||
* @license MIT | ||
* @license http://www.opensource.org/licenses/mit-license.php | ||
* @version v1.0.0 | ||
* | ||
* The latest version of CodeIgniter Gravatar Helper can be obtained from: | ||
* https://github.com/omkartapale/CodeIgniter-Gravatar-Helper | ||
*/ | ||
|
||
|
||
if (!function_exists('get_gravatar')) { | ||
|
||
/** | ||
* Get either a Gravatar URL or complete image tag for a specified email address. | ||
* | ||
* @param string $email The email address | ||
* @param int $s Size in pixels, defaults to 80px [ 1 - 2048 ] | ||
* @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] | ||
* @param string $r Maximum rating (inclusive) [ g | pg | r | x ] | ||
* @param bool $img True to return a complete IMG tag False for just the URL | ||
* @param array $atts Optional, additional key/value attributes to include in the IMG tag | ||
* @return String containing either just a URL or a complete image tag | ||
* @source http://gravatar.com/site/implement/images/php/ | ||
*/ | ||
function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { | ||
$url = 'http://www.gravatar.com/avatar/'; | ||
$url .= md5( strtolower( trim( $email ) ) ); | ||
$url .= "?s=$s&d=$d&r=$r"; | ||
if ( $img ) { | ||
$url = '<img src="' . $url . '"'; | ||
foreach ( $atts as $key => $val ) | ||
$url .= ' ' . $key . '="' . $val . '"'; | ||
$url .= ' />'; | ||
} | ||
return $url; | ||
} | ||
} |