Skip to content

Media bundle

Introduction

The goal of the media bundle is provide a library to easily handle files. With the MediaBundle you can create, store, download, modify files and make link them to entities that are saved in the database.

Installation

bash
$ composer require enhavo/media-bundle
bash
$ yarn add @enhavo/media
ts
// import statement
import MediaFormRegistryPackage from "@enhavo/media/FormRegistryPackage";

// register the package
this.registerPackage(new MediaFormRegistryPackage(application));
ts
// import
const MediaPackage = require('@enhavo/media/Encore/EncoreRegistryPackage');

// register package
.register(new MediaPackage());

If you want to display the media library in your application you can change your config/packages/enhavo.yaml file.

yaml
enhavo_app:
    menu:
        media_library:
            type: media_library

Commands

The Media bundle provide a few command line tools.

Refreshing

If you change filter setting or the code was changed. You need to refresh your formats.

bash
app/console enhavo:media:refresh-format --format="myFormatName"

You can also use the --id option to target a file.

Format

File formats are variants of media files. In order to keep the original file untouched, we use formats to change the content of files and save them separate.

To create a format we use filters that we can apply on the original file. If we want to use a set of different filters, we chain them together.

Enhavo comes already with a set of filters, that covers most of use cases. That includes resizing, compression and preview images out of pdfs and videos. For a full list of all filters check reference