# C. MediaLibrary

## New feature: media rework && media library

Concepts:

- library can manage files referenced using a "mapping"
- default mappings are "file" and "image"
- for each LinkedMediaType, mapping types must be configured using LinkedMedia attribute
- the form type is then only capable of displaying/adding in its mappings
- link is stored as string in database (json for collection) so multiple configurations are possible (heterogeneous media in same collection or multiple media usable for one simple link)
- media are now stored in a subdir matching Site slug
- Finally, all previous file/image systems are preserved and will be deprecated later.


## Usage

LinkedMediaType && LinkedMediaCollectionType

(yaml form type strings: linked_media && linked_media_collection)

-> Permit to soft-link media stored and access through media library.

```php
#[ORM\Column(type: Types::STRING, length: 255)]
#[LinkedMedia(mappings: ['image', 'file'])]
private ?string $linkedMedia = null;
```

```php
#[ORM\Column(type: Types::JSON)]
#[LinkedMedia(mappings: ['image'])]
private ?array $linkedMediaCollec = [];
```

## Upgrade requirements

New routing registering:

```yaml
# config\routes.yaml

# append in not already in routes file

app_extra:
  resource: .
  type: aa

```


## Unimplemented yet:

- mappings will later be able to isolate private files from public-accessed directories
- image media resize/crop
- media rename
- media translation edit (can be hacked to use default admin interfaces for mapping class)