PHPackages                             ldiro/media-bundle - 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. [Database &amp; ORM](/categories/database)
4. /
5. ldiro/media-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

ldiro/media-bundle
==================

Easier Symfony Form Media Management

5.2.7(6y ago)00PHPPHP &gt;=7.0.0

Since May 12Pushed 6y agoCompare

[ Source](https://github.com/Ldiro/MediaBundle)[ Packagist](https://packagist.org/packages/ldiro/media-bundle)[ Docs](https://github.com/Artgris/MediaBundle)[ RSS](/packages/ldiro-media-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (12)Versions (53)Used By (0)

artgris/MediaBundle - Easier Symfony Media Management
-----------------------------------------------------

[](#artgrismediabundle---easier-symfony-media-management)

### Prerequisites

[](#prerequisites)

- symfony &gt;= 4.1
- [artgris/FileManagerBundle](https://github.com/artgris/FileManagerBundle#add-following-configuration-)
- Assets:
    - CSS: [bootstrap](http://getbootstrap.com/) and [Font Awesome](http://fontawesome.io/)
    - JS: [jQuery](https://jquery.com/), [ninsuo/symfony-collection](https://github.com/ninsuo/symfony-collection) and [jQuery UI](https://jqueryui.com/)

[![demo-gif](https://github.com/artgris/MediaBundle/raw/master/demo.gif)](https://github.com/artgris/MediaBundle/raw/master/demo.gif)

### Getting Started

[](#getting-started)

- Download the files:

    ```
      composer require artgris/media-bundle

    ```
- In `AppKernel.php` add the bundle:

    ```
      new Artgris\Bundle\MediaBundle\ArtgrisMediaBundle()

    ```
- Then, run the following command:

    ```
      php bin/console assets:install

    ```
- In your twig template, you will then need to import the required assets:

    - CSS (**requires [bootstrap](http://getbootstrap.com/) and [Font Awesome](http://fontawesome.io/)**):

```
        {# Bootstrap #}

        {# Font Awesome #}

        {# Artgris FileManager #}

        {# Import fengyuanchen/cropper #}

        {# Then the default bundle's CSS #}

```

- JS (**requires [jQuery](https://jquery.com/), [ninsuo/symfony-collection](https://github.com/ninsuo/symfony-collection) and [jQuery UI](https://jqueryui.com/)**):

```
    {# jQuery #}

    {#  Bootstrap #}

    {#  Jqueri UI #}

    {# jquery.collection.js #}

    {# Import fengyuanchen/cropper #}

    {# Then the default bundle's JavaScript: #}
    {% include '@ArtgrisMedia/assets/include_js.html.twig' %}
```

- In `routing.yml`, you will need to import the Ajax route:

```
 artgris_media:
     resource: "@ArtgrisMediaBundle/Resources/config/routing.yml"
     prefix: /admin
```

### Usage

[](#usage)

In an entity, add the path attributes as string. You can also use doctrine's types such as `simple_array`, `array`, `json` for collections.

```
use Artgris\Bundle\MediaBundle\Form\Validator\Constraint as MediaAssert; // optionnal, to force image files

// ...

/**
 * @var string
 * @ORM\Column(type="string")
 * @Assert\NotNull()
 */
private $image;

/**
 * @var Collection|string[]
 * @ORM\Column(type="simple_array", nullable=true)
 * @MediaAssert\Image()
 */
private $gallery;
```

Then, use a form builder and assigne the `MediaType` class for a single file, or the `MediaCollectionType` for multiple files.

```
use Artgris\Bundle\MediaBundle\Form\Type\MediaType;
use Artgris\Bundle\MediaBundle\Form\Type\MediaCollectionType;

// ...

$builder
    ->add('image', MediaType::class, [
        'conf' => 'default'
    ])
    ->add('gallery', MediaCollectionType::class, [
        'conf' => 'default'
    ]);
```

### Options:

[](#options)

**MediaType:**

- `'conf' => 'yourconf'` (**required**) specifies a configuration defined in the FileManager. For more informations about media configurations, [refer to FileManagerBundle's documentation](https://github.com/artgris/FileManagerBundle#add-following-configuration-)
- `'readonly' => false` prevents the user from manually changing the path (it only adds a "readonly" attribute to the corresponding HTML input)
- `'allow_crop' => true` allows the user to edit the image using [fengyuanchen/cropper](https://github.com/fengyuanchen/cropper)
- `'crop_options' => array` if `allow_crop` is set to `true`, allows to specify extra crop options. The default options:

```
'crop_options' => [
    'display_crop_data' => true,    // will display crop box informations (x, y, width, height, and ratio if there is one)
    'allow_flip' => true,           // allows to flip the image vertically and horizontally
    'allow_rotation' => true,       // allows to rotate the image (90 degrees)
    'ratio' => false                // force a crop ratio. E.g 16/9
],
```

**MediaCollectionType:**

- `'conf' => 'yourconf'` (**required**) specifies a configuration defined in the FileManager. For more informations about media configurations, [refer to FileManagerBundle's documentation](https://github.com/artgris/FileManagerBundle#add-following-configuration-)

Some [ninsuo/symfony-collection](https://github.com/ninsuo/symfony-collection)'s options are available directly:

- `'min' => 0`
- `'max' => 100`
- `'init_with_n_elements' => 1`
- `'add_at_the_end' => true`

Like regular collections, you can edit entries options, i.e to enable alts:

```
'entry_options' => [
    'display_file_manager' => false
]
```

### Gregwar Image Bundle Integration

[](#gregwar-image-bundle-integration)

This bundle relies on [Gregwar/ImageBundle](https://github.com/Gregwar/ImageBundle) to crop, mirror and scale images.

If you need to manually crop image in twig (if they are too large for example), instead of using the `image` and `web_image` functions, you should `gImage`, which works the same as `image` but improves compatibility.

E.g:

```
{{ gImage(news.image).zoomCrop(100, 100) }}
```

### Changing cropping path

[](#changing-cropping-path)

add config/packages/artgris\_media.yaml

```
artgris_media:
    cropped_path: "cropped/" #default value

```

### Demo Application

[](#demo-application)

[MediaBundleDemo](https://github.com/artgris/MediaBundleDemo) is a complete Symfony application created to showcase MediaBundle features.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 67.5% 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 ~20 days

Recently: every ~31 days

Total

52

Last Release

2280d ago

Major Versions

1.1.2 → 2.0.02018-07-06

2.2 → 3.02018-09-30

3.0.1 → 4.0.02018-10-29

4.0.3 → v5.x-dev2019-01-28

PHP version history (2 changes)1.0PHP &gt;=5.3.3

2.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/03e34181961ade75704592321afb8227cea8927244139e15219296583c1f2286?d=identicon)[Ldiro](/maintainers/Ldiro)

---

Top Contributors

[![artgris](https://avatars.githubusercontent.com/u/22889596?v=4)](https://github.com/artgris "artgris (56 commits)")[![Arkounay](https://avatars.githubusercontent.com/u/9340719?v=4)](https://github.com/Arkounay "Arkounay (24 commits)")[![Ldiro](https://avatars.githubusercontent.com/u/35108257?v=4)](https://github.com/Ldiro "Ldiro (2 commits)")[![linkrb](https://avatars.githubusercontent.com/u/900590?v=4)](https://github.com/linkrb "linkrb (1 commits)")

---

Tags

symfonybundledoctrinemediaform

### Embed Badge

![Health badge](/badges/ldiro-media-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ldiro-media-bundle/health.svg)](https://phpackages.com/packages/ldiro-media-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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