PHPackages                             ed.sukharev/twig-picture-extension - 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. ed.sukharev/twig-picture-extension

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

ed.sukharev/twig-picture-extension
==================================

A Twig extension to generate picture tags

1.0.0(7y ago)041MITPHPPHP &gt;=5.3.3

Since May 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/eduard-sukharev/TwigPictureExtension)[ Packagist](https://packagist.org/packages/ed.sukharev/twig-picture-extension)[ Docs](https://github.com/eduard-sukharev/TwigPictureExtension)[ RSS](/packages/edsukharev-twig-picture-extension/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (4)Versions (2)Used By (0)

TwigPictureExtension
====================

[](#twigpictureextension)

A custom twig extension to add  tags with multiple source type to aid new image types adoption (WebP now).

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

[](#installation)

Add the library to your app's `composer.json`:

```
    "require": {
        "ed.sukharev/twig-picture-extension": "~1.0",
        ...
    }
```

Add the extension to the `Twig_Environment`:

```
use PictureExtension\Twig\Extension\Picture;

$twig = new Twig_Environment(...);

$twig->addExtension(new Picture());
```

Usage
-----

[](#usage)

The extension provides a `picture` twig function, which generates a **picture** tag with a set of **source**s and fallback **img** tag:

```
{{ picture('/img/path/filename.png', 'My image alt text') }}
```

Which creates following output:

```

```

### Arguments

[](#arguments)

The `picture` function accepts 3 arguments:

```
picture($filename, $imgAlt, $imgClasses = [])
```

- **filename**: The filename of original image. Picture function substitutes the extension with appropriate when needed.
- **alt**: This is alternative text to be shown when image not available. Required so that you don't forget to add it.
- **imgClasses**: Array of strings to be added to `class` attribute of fallback `img` tag.

Symfony2
--------

[](#symfony2)

### Add a service manually

[](#add-a-service-manually)

```
# app/config/config.yml

services:
    pciture_extension.twig.picture:
        class: PictureExtension\Twig\Extension\Picture
        tags:
            - { name: twig.extension }
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2559d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe156a4d3014d5a3329ed208a2be772052b0dc2d6c4622e01194470793618acd?d=identicon)[eduard-sukharev](/maintainers/eduard-sukharev)

---

Top Contributors

[![eduard-sukharev](https://avatars.githubusercontent.com/u/3235378?v=4)](https://github.com/eduard-sukharev "eduard-sukharev (1 commits)")

---

Tags

twigimagespictures

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/edsukharev-twig-picture-extension/health.svg)

```
[![Health](https://phpackages.com/badges/edsukharev-twig-picture-extension/health.svg)](https://phpackages.com/packages/edsukharev-twig-picture-extension)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91292.0M315](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36663.2M221](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

21946.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21814.8M162](/packages/symfony-ux-twig-component)

PHPackages © 2026

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