Giter Site home page Giter Site logo

php-gravatar's Introduction

# README #

META

Name:			Class Gravatar
Version:		1.1
Description:	A PHP class to make using Gravatar easier

AUTHOR

Original class by
	Lucas Araújo <[email protected]>
	(all credit goes to this guy)
	
GitHub fork and existence check by:
	Tyler Christensen <[email protected]>
	www.codeprinciples.com

README

From Gravatar Help:
	"A gravatar is a dynamic image resource that is requested from our server. The request
	URL is presented here, broken into its segments."
	
Source:
	http://site.gravatar.com/site/implement

First of all, this class was not written by me. We owe it to Lucas Araújo
<[email protected]> who wrote the original Gravatar class in PHP. All
I did was copy it to GitHub and add/modify some functionality:

	- now supports checking to see if a Gravatar image actually exists
	- returns the Gravatar URL by default, instead of an image tag
	- visibility of the $this->email property is now public
	
The class still supports the $default image thing if you'd like to use it,
but it'd probably be better to check if a Gravatar exists beforehand and
then act accordingly in your implementation.

Lucas's original implementation may be found at:
	http://www.phpclasses.org/browse/package/4227.html
	
USAGE

The following code will check to see if a Gravatar exists, and if so, show
it with no parameters.

<code>

	$email = "[email protected]";
	$gravatar = new Gravatar($email);	// create new Gravatar with email
	$gravatar->size = 128;
	$gravatar->rating = "G";
	
	if ($gravatar->gravatarExists()) {
		echo '<img src="' . $gravatar . '" alt="" />';	
	} else {
		echo 'No Gravatar exists for this email address';
	}
	
</code>

A sample PHP program is included that shows a similar demonstration and can
be run on your own server without modification.

OTHER FUNCTIONS

$Grav = new Gravatar( [$email, [$default]] );	// make a Gravatar object
bool $Grav->setEmail($email);
bool $Grav->setDefault($default);
bool $Grav->setRating($rating);					// maximum rating (G,PG,R,X)
bool $Grav->setSize($size);						// size to get URL of
bool $Grav->setExtra($extra);					// parameters to add to img tag

bool $Grav->gravatarExists();					// check if Gravatar exists
string $Grav->imageTag()						// get a complete <img> tag
string $Grav->gravatarLink()					// get the Gravatar.com URL

echo $Grav										// same as $Grav->gravatarLink()

php-gravatar's People

Contributors

tylerchr avatar

Stargazers

Miguel Angel avatar

Watchers

Miguel Angel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.