PHPackages                             ry167/twig-gravatar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. ry167/twig-gravatar

ActiveLibrary[Templating &amp; Views](/categories/templating)

ry167/twig-gravatar
===================

Gravatar filters for Twig templates

3.0.0(8y ago)24.7k3[2 issues](https://github.com/ry167/twig-gravatar/issues)MITPHPCI failing

Since Apr 16Pushed 6y ago2 watchersCompare

[ Source](https://github.com/ry167/twig-gravatar)[ Packagist](https://packagist.org/packages/ry167/twig-gravatar)[ Docs](https://github.com/ry167/twig-gravatar)[ RSS](/packages/ry167-twig-gravatar/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

Twig Gravatar
=============

[](#twig-gravatar)

[![Latest Version](https://camo.githubusercontent.com/0184c72132e4513ea649fe1929d3f8cd11ab8d4cf0b0fd089da54bf29d78bebb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f72793136372f747769672d67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://github.com/ry167/twig-gravatar/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/0b80a824120714f6bdd22ccbcdbffd39e42c64079fe961fa43dfa6b659565d62/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f72793136372f747769672d67726176617461722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ry167/twig-gravatar)[![Quality Score](https://camo.githubusercontent.com/6269aca882adf6c6b68c6fd92bdfa7cec8019f90f898677e40e8a09a4831b19b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f72793136372f747769672d67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ry167/twig-gravatar)[![Total Downloads](https://camo.githubusercontent.com/99e6db3036a52d2b5b3107e08abb034c649cce1cd2ebafc87e34d0143e299237/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72793136372f747769672d67726176617461722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ry167/twig-gravatar)

An extension for Twig that provides simple filters for Gravatar.

Installation
------------

[](#installation)

Use `composer` to install this extension:

```
composer require ry167/twig-gravatar 3.0.0
```

Usage
-----

[](#usage)

```
require("vendor/autoload.php");

//Define your Twig Environment and Twig Loader
$twig->addExtension(new \TwigGravatar());

//or create a customized Twig Gravatar instance
new \TwigGravatar($default = null, $size = null, $filterPrefix = 'gr', $rating = null, $useHttps = true);
```

Usage in Symfony
----------------

[](#usage-in-symfony)

```
    twig.extension.gravatar:
        class: \TwigGravatar
        arguments:
            $default: ~         e.g. 'monsterid'
            $size: ~            e.g. 50
            $filterPrefix: ~    e.g. 'foo'
            $rating: ~          e.g. 'x'
            $useHttps: true
        tags:
            - { name: twig.extension }
```

You can also remove the arguments section and the default values will be used.

Filters
-------

[](#filters)

This Extension is designed so that you chain together the filters that you need on top of each other. You must however always start with the grAvatar filter.

### grAvatar

[](#gravatar)

Create a Gravatar URL, This returns just the URL for the persons avatar image without the `` tag

```
{{ 'example@example.com'|grAvatar }}
```

### grHttps

[](#grhttps)

Change a Gravatar URL to its secure counterpart.

```
{{ 'example@example.com'|grAvatar|grHttps }}
```

### grSize

[](#grsize)

Change the Size of the Gravatar Image to the specified size in pixels.

```
{{ 'example@example.com'|grAvatar|grSize(1024) }}
```

Gravatar does not serve images greater than `2048px`, and they are all squares.

### grDefault

[](#grdefault)

Specify a default image for if the User does not have one defined

```
{{ 'example@example.com'|grAvatar|grDefault('http://example.com/default.png') }}
```

You can also use any of Gravatar's built in default images, [you can see them here](http://en.gravatar.com/site/implement/images/#default-image). Just use the code assigned to them such as `mm` instead of your Image URL.

### grRating

[](#grrating)

Specify a maximum rating that the image can be. Valid values are `g`, `pg`, `r` and `x`.

```
{{ 'example@example.com'|grAvatar|grRating('pg') }}
```

Prefix
------

[](#prefix)

You can change the filter prefix from `gr` to something else by changing its value in constructor.

```
//Define your Twig Environment and Twig Loader

$TwigGravatar = new \TwigGravatar(null, null, 'foo');

$twig->addExtension($TwigGravatar);
//Filters are now 'fooAvatar' etc
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 70.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~291 days

Recently: every ~317 days

Total

7

Last Release

2350d ago

Major Versions

1.0.1 → 2.0.02016-08-03

2.0.2 → 3.0.02018-04-07

3.0.0 → 4.0.0-RC2020-01-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/15303f7420244e8a44371e6c30257d1ab62097f48163f606d809089723670a38?d=identicon)[ry167](/maintainers/ry167)

---

Top Contributors

[![ryanhalliday](https://avatars.githubusercontent.com/u/961043?v=4)](https://github.com/ryanhalliday "ryanhalliday (24 commits)")[![robertfausk](https://avatars.githubusercontent.com/u/1651297?v=4)](https://github.com/robertfausk "robertfausk (6 commits)")[![clubdesarrolladores](https://avatars.githubusercontent.com/u/1078601?v=4)](https://github.com/clubdesarrolladores "clubdesarrolladores (1 commits)")[![HelgeSverre](https://avatars.githubusercontent.com/u/1089652?v=4)](https://github.com/HelgeSverre "HelgeSverre (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![StuartLeads2Trade](https://avatars.githubusercontent.com/u/33313933?v=4)](https://github.com/StuartLeads2Trade "StuartLeads2Trade (1 commits)")

---

Tags

twiggravatar

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ry167-twig-gravatar/health.svg)

```
[![Health](https://phpackages.com/badges/ry167-twig-gravatar/health.svg)](https://phpackages.com/packages/ry167-twig-gravatar)
```

###  Alternatives

[symfony/ux-twig-component

Twig components for Symfony

22018.6M355](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1647.0M128](/packages/symfony-ux-live-component)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

16126.1k1](/packages/symfony-ux-toolkit)[mati365/ckeditor5-symfony

CKEditor 5 integration for Symfony

262.6k](/packages/mati365-ckeditor5-symfony)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
