Download the PHP package thomaswelton/gravatarlib without Composer

On this page you can find all versions of the php package thomaswelton/gravatarlib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gravatarlib

GravatarLib

GravatarLib is a small library intended to provide easy integration of gravatar-provided avatars.

copyright

(c) 2011 emberlabs.org

license

This library is licensed under the MIT license; you can find a full copy of the license itself in the file /LICENSE

requirements

usage

We'll assume you're using this git repository as a git submodule, and have it located at includes/emberlabs/GravatarLib/ according to namespacing rules, for easy autoloading.

general example

setting the default image

Gravatar provides several pre-fabricated default images for use when the email address provided does not have a gravatar or when the gravatar specified exceeds your maximum allowed content rating. The provided images are 'mm', 'identicon', 'monsterid', 'retro', and 'wavatar'. To set the default iamge to use on your site, use the method \emberlabs\GravatarLib\Gravatar->setDefaultImage() In addition, you can also set your own default image to be used by providing a valid URL to the image you wish to use.

Here are a couple of examples...

WARNING

If an invalid default image is specified (both an invalid prefab default image and an invalid URL is provided), this method will throw an exception of class \InvalidArgumentException.

setting avatar size

Gravatar allows avatar images ranging from 1px to 512px in size -- and you, the developer or site administrator can specify the exact size of avatar that you want. By default, the avatar size provided is 80px. To set the avatar size for use on your site, use the method \emberlabs\GravatarLib\Gravatar->setAvatarSize(), and specify the avatar size with an integer representing the size in pixels.

An example of setting the avatar size is provided below:

WARNING

If an invalid size (less than 1, greater than 512) or a non-integer value is specified, this method will throw an exception of class \InvalidArgumentException.

setting the maximum content rating

Gravatar provides four levels for rating avatars by, which are named similar to entertainment media ratings scales used in the United States. They are, by order of severity (first is safe for everyone to see, last is explicit), "g", "pg", "r", and "x". By default, the maximum content rating is set to "g". You can set the maximum allowable rating on avatars embedded within your site by using the method \emberlabs\GravatarLib\Gravatar->setMaxRating(). Please note that any avatars that do not fall under your maximum content rating will be replaced with the default image you have specified.

Here's an example of how to set the maximum content rating:

WARNING

If an invalid maximum rating is specified, this method will throw an exception of class \InvalidArgumentException.

enabling secure images

If your site is served over HTTPS, you'll likely want to serve gravatars over HTTPS as well to avoid "mixed content warnings". To enable "secure images" mode, call the method \emberlabs\GravatarLib\Gravatar->enableSecureImages() before generating any gravatar URLs. To check to see if you are using "secure images" mode, call the method \emberlabs\GravatarLib\Gravatar->usingSecureImages(), which will return a boolean value regarding whether or not secure images mode is enabled.

twig integration

It's extremely easy to hook this library up as a template asset to the Twig template engine.

When you've got an instance of the Twig_Environment ready, add in your instantiated gravatar object as a twig "global" like so:

Now in your twig templates, you can get a user's gravatar with something like this snip of code:

(note: this template snip assumes that the "email" template variable contains the email of the user to grab the gravatar for)

We are also using the raw filter here to preserve XHTML 1.0 Strict compliance; the generated gravatar URL contains the & character, and if the filter was not used it would be double-escaped.


All versions of gravatarlib with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package thomaswelton/gravatarlib contains the following files

Loading the files please wait ....