Giter Club home page Giter Club logo

laravel-gravatar's Introduction

Build Status Latest Stable Version Total Downloads Bitdeli Badge

Installation

Update your composer.json file to include this package as a dependency

"thomaswelton/laravel-gravatar": "0.0.x"

Register the Gravatar service provider by adding it to the providers array in the app/config/app.php file.

Thomaswelton\LaravelGravatar\LaravelGravatarServiceProvider

Alias the Gravatar facade by adding it to the aliases array in the app/config/app.php file.

'aliases' => array(
	'Gravatar' => 'Thomaswelton\LaravelGravatar\Facades\Gravatar'
)

Configuration - Optional

Copy the config file into your project by running

php artisan config:publish thomaswelton/laravel-gravatar

Default Image

Update the config file to specify the default avatar size to use and a default image to be return if no Gravatar is found.

Allowed defaults:

  • (bool) false
  • (string) 404
  • (string) mm: (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash).
  • (string) identicon: a geometric pattern based on an email hash.
  • (string) monsterid: a generated 'monster' with different colors, faces, etc.
  • (string) wavatar: generated faces with differing features and backgrounds.
  • (string) retro: awesome generated, 8-bit arcade-style pixelated faces.

Example images can be viewed on the Gravatar website.

Content Ratings

By default only "G" rated images will be shown. You can change this system wide in the config file by editing 'maxRating' => 'g' allowed values are

  • g: suitable for display on all websites with any audience type.
  • pg: may contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.
  • r: may contain such things as harsh profanity, intense violence, nudity, or hard drug use.
  • x: may contain hardcore sexual imagery or extremely disturbing violence.

The content rating can be changed by changing the $rating argument when calling Gravatar::src or Gravatar::image.

Usage

Gravatar::exists($email)

Returns a boolean telling if the given $email has got a Gravatar.

Gravatar::src($email, $size = null, $rating = null)

Returns the https URL for the Gravatar of the email address specified. Can optionally pass in the size required as an integer. The size will be contained within a range between 1 - 512 as gravatar will no return sizes greater than 512 of less than 1

<!-- Show image with default dimensions -->
<img src="{{ Gravatar::src('[email protected]') }}">

<!-- Show image at 200px -->
<img src="{{ Gravatar::src('[email protected]', 200) }}">

<!-- Show image at 512px scaled in HTML to 1024px -->
<img src="{{ Gravatar::src('[email protected]', 1024) }}" width=1024>

Gravatar::image($email, $alt = null, $attributes = array(), $rating = null)

Returns the HTML for an <img> tag

// Show image with default dimensions
echo Gravatar::image('[email protected]');

// Show image at 200px
echo Gravatar::image('[email protected]', 'Some picture', array('width' => 200, 'height' => 200));

// Show image at 512px scaled in HTML to 1024px
echo Gravatar::image('[email protected]', 'Some picture', array('width' => 1024, 'height' => 1024));

laravel-gravatar's People

Contributors

thomaswelton avatar antoineaugusti avatar emilsundberg avatar kennedytedesco avatar

Watchers

James Cloos avatar Andrei 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.