heimrichhannot / contao-media-library-bundle
Add a Media Library to your Contao CMS Web Application.
Installs: 931
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:contao-bundle
pkg:composer/heimrichhannot/contao-media-library-bundle
Requires
- php: ^8.2
- ausi/slug-generator: ^1.0
- contao/core-bundle: ^4.13 || ^5.3
- heimrichhannot/contao-encore-contracts: ^1.0
- heimrichhannot/contao-flare-bundle: >=0.0.29
- heimrichhannot/contao-form-type-bundle: ^0.2.0
- heimrichhannot/contao-utils-bundle: ^2.220 || ^3.0
- symfony/config: ^5.4 || ^6.4 || ^7.0
- symfony/event-dispatcher-contracts: ^1.0 || ^2.0 || ^3.0
- symfony/translation-contracts: ^1.0 || ^2.0 || ^3.0
Suggests
- codefog/tags-bundle: ^3.2
- heimrichhannot/contao-categories-bundle: ^1.1
- heimrichhannot/contao-filecredits-bundle: ^2.1
Conflicts
- heimrichhannot/contao-filecredits-bundle: <2.1.0
- heimrichhannot/contao-flare-bundle: <0.0.13
- v2.x-dev
- 2.0.0-beta.17
- 2.0.0-beta.16
- 2.0.0-beta.15
- 2.0.0-beta.14
- 2.0.0-beta.13
- 2.0.0-beta.12
- 2.0.0-beta.11
- 2.0.0-beta.10
- 2.0.0-beta.9
- 2.0.0-beta.8
- 2.0.0-beta.7
- 2.0.0-beta.6
- 2.0.0-beta.5
- 2.0.0-beta.4
- 2.0.0-beta.3
- 2.0.0-beta.2
- 2.0.0-beta.1
- 2.0.0-beta.0
- v1.x-dev
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 1.0.0-beta23
- 1.0.0-beta22
- 1.0.0-beta21
- 1.0.0-beta20
- 1.0.0-beta19
- 1.0.0-beta18
- 1.0.0-beta17
- 1.0.0-beta16
- 1.0.0-beta15
- 1.0.0-beta14
- 1.0.0-beta13
- 1.0.0-beta12
- 1.0.0-beta11
- 1.0.0-beta10
- 1.0.0-beta9
- 1.0.0-beta8
- 1.0.0-beta7
- 1.0.0-beta6
- 1.0.0-beta5
- 1.0.0-beta4
- 1.0.0-beta3
- 1.0.0-beta2
- 1.0.0-beta
- 0.11.0
- 0.10.1
- 0.10.0
- 0.9.2
- 0.9.1
- 0.9.0
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.1
- 0.7.0
- 0.6.4
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- dev-feature/create-permission
- dev-feature/support_new_delete_permissions
- dev-feature/delete-product-permissions
- dev-feature/enhance_copyright
This package is auto-updated.
Last update: 2025-12-11 16:10:23 UTC
README
The Contao Media Library Bundle provides archive‑based management of media library items (such as images, videos, and files) and their downloadable files.
Features
- Organize your media as objects in archives
- Predefined media library product types:
image,video,file - For image archives, define image sizes that are used to automatically create downloads
- Individually add additional DCA fields to the archives and their items
- Automatically generate downloads for images in desired formats and dimensions
- Upload and edit media library items directly from the frontend with a form generator preset form-type
- Integration with FLARE Bundle to list media libraries, e.g., in gallery views
- Integration with Form Type Bundle to handle form submissions with media library items
- Integration with Encore Bundle to easily add the media library assets to your frontend
- Optional: Integration with Codefog Tags Bundle to tag items
- Optional: Integration with H & H Categories Bundle to categorize items
- Optional: Integration with H & H Filecredits Bundle (private) to ease assignment of file credits to the files of items
Installation
Install the bundle via Composer and update the database afterwards.
composer require heimrichhannot/contao-media-library-bundle
Setup
- Create a media library archive and configure its settings.
- Create an entry in this archive.
- Optional: Manually add additional files or file variants.
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
You can enable edit and delete support for media library products by activating the corresponding options in the archive settings.
Make sure to configure the member (and/or member group) permissions accordingly.
If a front end member has the required permissions, edit and delete links are automatically added to the template data of reader bundle templates.
The variables are available as editLink and deleteLink.
Developers
Events
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
HeimrichHannot\MediaLibraryBundle\Event\ArchiveEditEvent
HeimrichHannot\MediaLibraryBundle\Event\ItemEditEvent
Fired when an archive or item is edited, respectively. Can be used modify the DCA or translations.
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
<?php # src/MediaLibrary/MyMediaLibraryArchive.php namespace App\MediaLibrary; use HeimrichHannot\MediaLibraryBundle\ArchiveType\AbstractArchiveType; use Symfony\Component\EventDispatcher\Attribute\AsEventListener; class MyMediaLibraryArchive extends AbstractArchiveType { public const TYPE = 'app_myMlArchiveType'; public static function getAlias(): string { return self::TYPE; } }
Extended Example
<?php # src/MediaLibrary/MyMediaLibraryArchive.php namespace App\MediaLibrary; use HeimrichHannot\MediaLibraryBundle\ArchiveType\AbstractArchiveType; use Symfony\Component\EventDispatcher\Attribute\AsEventListener; class MyMediaLibraryArchive extends AbstractArchiveType { public const TYPE = 'app_myMlArchiveType'; public static function getAlias(): string { return self::TYPE; } /* ================ IMPLEMENT CONFIG METHODS ================ *\ * The following methods have default implementations in * * AbstractArchiveType, but can be overridden if necessary. * \* ========================================================== */ public function getItemPalette(ArchiveModel $archive, ItemModel $item): string { return parent::getItemPalette($archive, $item); } public function getArchivePalette(ArchiveModel $archive): string { return parent::getArchivePalette($archive); } public function supportsImageSizeDownloads(ArchiveModel $archive): bool { return parent::supportsImageSizeDownloads($archive); } /* ================ EXAMPLE EVENT LISTENERS ================ *\ * The following methods are examples of event listeners * * that you can implement to customize the behavior of your * * media library archive types or even existing ones. * \* ========================================================== */ #[AsEventListener] public function alterTranslations(ItemEditEvent $event): void { if ($event->archiveType !== self::TYPE) { return; } $trans = &$GLOBALS['TL_LANG'][ItemModel::getTable()]; $trans['file'] = ['Vorschaubild', 'Wählen Sie ein Thumbnail für das Archiv aus.']; $trans['addAdditionalFiles'] = ['Dateien zum Herunterladen anbieten', 'Bieten Sie Dateien zum Download an.']; $trans['additionalFiles'] = ['Herunterladbare Dateien auswählen', 'Hier können Sie die Dateien auswählen, die zum Download angeboten werden sollen.']; } #[AsEventListener] public function onItemPalette(ItemPaletteEvent $event): void { if ($event->archiveType !== self::TYPE) { return; } $event->prefix = PaletteManipulator::create() ->removeField('tags') ->removeField('text') ->applyToString($event->prefix); $event->suffix = '{details_legend},tags,text;' . $event->suffix; } }