Developed with love by KnpLabs Hire us for your project!
156

GravatarBundle

by ornicar

Simple wrapper to gravatar API for Symfony2 - Provides a configurable service and a template helper

OrnicarGravatarBundle

Build Status

Installation

  1. Add this bundle to your projects composer.json

    "require": { 
      "ornicar/gravatar-bundle" : "dev-master"
    }
    
  2. Run composer update to install the bundle and regenerate the autoloader

    $ composer.phar update
    
  3. Add this bundle to your application's kernel:

    // application/ApplicationKernel.php
    public function registerBundles()
    {
      return array(
          // ...
          new Ornicar\GravatarBundle\OrnicarGravatarBundle(),
          // ...
      );
    }
    
  4. Configure the gravatar service, templating helper and Twig extension in your config:

    # application/config/config.yml
    ornicar_gravatar: ~
    
  5. If you always have some default for your gravatars such as size, rating or default it can be configured in your config

    # application/config/config.yml
    ornicar_gravatar:
    rating: g
    size: 80
    default: mm
    

Usage

All you have to do is use the helper like this example:

<img src="<?php echo $view['gravatar']->getUrl('alias@domain.tld') ?>" />

Or with parameters:

<img src="<?php echo $view['gravatar']->getUrl('alias@domain.tld', '80', 'g', 'defaultimage.png', true) ?>" />

The only required parameter is the email adress. The rest have default values.

If you use twig you can use the helper like this example:

<img src="{{ gravatar('alias@domain.tld') }}" />

Or if you want to check if a gravatar email exists:

{% if gravatar_exists('alias@domain.tld') %}
  The email is an gravatar email
{% endif %}

Or with parameters:

<img src="{{ gravatar('alias@domain.tld', size, rating, default, secure) }}" />

For more information look at the gravatar implementation pages.

The MIT License

Copyright (c) 2010 Thibault Duplessis, Clément JOBEILI, Henrik Bjørnskov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Merge pull request #32 from Soullivaneuh/secure-option-ternary
    By henrikbjorn, 2 years ago
  • Ternary conditional for secure option. Asked on #31
    By Soullivaneuh, 2 years ago
  • Merge pull request #31 from Soullivaneuh/secure-option-fix
    By henrikbjorn, 2 years ago
  • Fix secure gravatar option testing
    By Soullivaneuh, 2 years ago
  • Merge pull request #30 from xavierfaucon/patch-1
    By henrikbjorn, 2 years ago
  • Update README.markdown
    By , 2 years ago
  • Merge pull request #28 from nurikabe/master
    By henrikbjorn, 3 years ago
  • Move exceptional case to top of method. Return null if connection could not be made.
    By nurikabe, 3 years ago
  • Don't crash if there is a DNS hiccup.
    By nurikabe, 3 years ago
  • Merge pull request #27 from piotrantosik/master
    By henrikbjorn, 3 years ago
  • Update composer.json
    By piotrantosik, 3 years ago
  • Merge pull request #26 from mhor/patch-1
    By henrikbjorn, 3 years ago
  • Syntax highlighting on README.markdown
    By mhor, 3 years ago
  • Merge pull request #25 from fabstei/patch-1
    By henrikbjorn, 3 years ago
  • Small Typo
    By fabstei, 3 years ago
  • Merge pull request #24 from dVelopment/master
    By henrikbjorn, 3 years ago
  • - added Twig to require-dev for unit tests
    By dVelopment, 3 years ago
  • added "secure" as another defaults config option
    By dVelopment, 3 years ago
  • Merge pull request #23 from wwotoole/patch-1
    By henrikbjorn, 3 years ago
  • Modify function exists to improve consistency of results
    By wwotoole, 3 years ago
  • Merge pull request #22 from lemoinem/features/offline-use
    By henrikbjorn, 3 years ago
  • Remove dependecie on Request to make the Service available offline (via console Commands)
    By lemoinem, 3 years ago
  • add whitespace to a test to test that whitespace is trimmed\
    By henrikbjorn, 3 years ago
  • Use the new autoload path in bootstrap file
    By henrikbjorn, 3 years ago
  • Trim email before hash
    By ndavoust, 4 years ago
  • Change instructions for installing to use composer. Fix #17
    By henrikbjorn, 4 years ago
  • Merge pull request #15 from henrikbjorn/composer
    By henrikbjorn, 5 years ago
  • composer install --install-suggests is broken
    By henrikbjorn, 5 years ago
  • install suggests
    By henrikbjorn, 5 years ago
  • Skip test if Twig isnt present
    By henrikbjorn, 5 years ago