alexeevdv / twig-gravatar-filter
1.0.0
2018-12-04 16:01 UTC
Requires
- twig/twig: ^1.27|^2.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2024-11-05 04:18:24 UTC
README
This is Twig filter which converts email to Gravatar image url.
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require alexeevdv/twig-gravatar-filter "^1.0"
or add
"alexeevdv/twig-gravatar-filter": "^1.0"
to the require
section of your composer.json
file.
Configuration
Symfony
twig.extension.gravatar:
class: \alexeevdv\twig\GravatarFilter
tags:
- { name: twig.extension }
Standalone
$twig->addExtension(new \alexeevdv\twig\GravatarFilter);
Usage
Without parameters
<img src="{{ 'email@example.org' | gravatar }}" /> <!-- will result in following html --> <img src="https://secure.gravatar.com/avatar/8fbf4bd0581c9ccc67c560dea9931a1b" />
With different parameters
<img src="{{ 'email@example.org' | gravatar({'size': 500, 'forceDefault': true, 'defaultImage': 'mm', 'rating': 'pg', 'extension': true}) }}" /> <!-- will result in following html --> <img src="https://secure.gravatar.com/avatar/8fbf4bd0581c9ccc67c560dea9931a1b.jpg?s=500&f=y&d=mm&r=pg" />
Parameters
For possible values please refer to Gravatar documentation