PHPackages                             heimrichhannot/contao-media-library-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. [File &amp; Storage](/categories/file-storage)
4. /
5. heimrichhannot/contao-media-library-bundle

ActiveContao-bundle[File &amp; Storage](/categories/file-storage)

heimrichhannot/contao-media-library-bundle
==========================================

Add a Media Library to your Contao CMS Web Application.

1.6.0(1y ago)01.2k↑66.7%LGPL-3.0-or-laterPHPPHP ^8.1

Since Apr 25Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-media-library-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-media-library-bundle)[ RSS](/packages/heimrichhannot-contao-media-library-bundle/feed)WikiDiscussions v2 Synced 3w ago

READMEChangelog (10)Dependencies (10)Versions (104)Used By (0)

Contao Media Library Bundle
===========================

[](#contao-media-library-bundle)

[![](https://camo.githubusercontent.com/df0e5301b6b1ec1ee16f1ef3b0333c62f1b4c5fc94aa7929e4e3660e38ddfc98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d6d656469612d6c6962726172792d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-media-library-bundle)[![](https://camo.githubusercontent.com/8ba6557e2489c86601b32988d328c28aa1d68b9e1cfad8975013e612212751ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d6d656469612d6c6962726172792d62756e646c652e737667)](https://packagist.org/packages/heimrichhannot/contao-media-library-bundle)

The Contao Media Library Bundle provides archive‑based management of media library items (such as images, videos, and files) and their downloadable files.

Features
--------

[](#features)

- Organize your media as objects in archives
- Predefined media library item types: `image`, `video`, `file`
- For image archives, define image sizes to automatically create downloads in desired formats and dimensions
- Upload and edit media library items directly from the frontend with a form generator preset form-type
- Add custom DCA fields to individual archives and their items
- Integration with [FLARE Bundle](https://github.com/heimrichhannot/conta-flare-bundle) to list media libraries, e.g., in gallery views
- Integration with [Form Type Bundle](https://github.com/heimrichhannot/contao-form-type-bundle) to handle frontend form submissions with media library items
- Optional: Integration with [Codefog Tags Bundle](https://github.com/codefog/tags-bundle) to tag items
- Optional: Integration with [H &amp; H Categories Bundle](https://github.com/heimrichhannot/contao-categories-bundle) to categorize items
- Optional: Integration with [H &amp; H Filecredits Bundle (private)](https://github.com/heimrichhannot/contao-filecredits-bundle) to ease assignment of file credits to the files of items

---

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

[](#installation)

Install the bundle via Composer and update the database afterwards.

```
composer require heimrichhannot/contao-media-library-bundle
```

Setup
-----

[](#setup)

1. Create a media library archive and configure its settings.
2. Create an entry in this archive.
3. Optional: Manually add additional files or file variants.

Configuration
-------------

[](#configuration)

```
huh_media_library:
    # Default upload path for media library items when using the frontend form
    file_upload_path: 'files/media-library/##author##/##title##'
```

---

Editing and deleting products
-----------------------------

[](#editing-and-deleting-products)

Enable edit and delete functionality for media library items by turning on the corresponding options in the archive settings. Also verify that member (and/or member group) permissions are configured appropriately.

### Editing items directly from the frontend

[](#editing-items-directly-from-the-frontend)

1. Set up your custom upload and/or edit form in the form-generator using the supplied `MediaLibraryType` form-type.
    - You may use the identical form for both actions, uploading and editing, given that you want the same fields to be present.
    - Otherwise, create separate forms for each action or refer to the [contao-form-type-bundle's documentation](https://github.com/heimrichhannot/contao-form-type-bundle)for information on how to modify a form programatically.
2. Create an upload and/or edit page with a form content element configured to use the previously set up form. The page will then automatically assure that any accessing frontend member is authorized to upload or edit the individual media library item.
3. In a flare reader template, you may use the below snippet to display an edit link for a media library item.
    - An endpoint for deleting items is road-mapped; full functionality is not available yet.

```
{% if is_granted('ml_item_edit', model) %}
    {% set pageEdit = archive.related('editJumpTo') %}
    {% if pageEdit %}
        edit
    {% endif %}
{% endif %}
```

---

Developers
----------

[](#developers)

### Events

[](#events)

#### Modify Palette

[](#modify-palette)

`HeimrichHannot\MediaLibraryBundle\Event\`**`ArchivePaletteEvent`**
`HeimrichHannot\MediaLibraryBundle\Event\`**`ItemPaletteEvent`**

Fired when the palette of an archive or item is generated. Can be used to add additional fields.

#### Backend Editing

[](#backend-editing)

`HeimrichHannot\MediaLibraryBundle\Event\`**`ArchiveEditEvent`**
`HeimrichHannot\MediaLibraryBundle\Event\`**`ItemEditEvent`**

Fired when an archive or item is edited, respectively. Can be used to modify the DCA or translations.

### Custom Media Library Archive Types

[](#custom-media-library-archive-types)

Any class that extends `HeimrichHannot\MediaLibraryBundle\ArchiveType\AbstractArchiveType` will be automatically registered as a media library archive type and be available in the archive settings.

#### Minimal working Boilerplate

[](#minimal-working-boilerplate)

```
