jolicode / jolicode/MediaBundle

Feature request: native multi-media entity field support (gallery use case)

Open
#89 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
118
Forks
13
Avg merge
22h 54m
Merged PRs (30d)
3

Description

## Summary
Add native support for **multi-media entity fields** (array/list of media paths) in JoliMedia + EasyAdmin bridge.

Today, `MediaChoiceType` and Doctrine media types target a single media value. For common use cases like **photo galleries**, integrators must introduce an extra join entity (e.g. `ServiceGalleryImage`) only to store multiple media references and ordering.

## Why this is needed
A lot of projects need to attach multiple images/files directly on one entity field, for example:
- service page gallery photos
- product gallery images
- project portfolio images

Current workaround:
- create a dedicated child entity (`...GalleryImage`)
- manage OneToMany + ordering manually
- extra migration/model complexity for a simple list of paths

## Proposal
### 1) Doctrine type for media lists
Add a new Doctrine type (example naming):
- `Types::MEDIA_JSON` (or `MEDIA_ARRAY`)

Behavior:
- DB storage as JSON array of normalized media paths
- PHP value as `list` or `list` (clear contract to define)
- path normalization on write

### 2) EasyAdmin form support for multi-select
Provide either:
- `MediaChoiceType` with `multiple: true`, or
- a dedicated `MediaCollectionType` / `MediaGalleryType`

Expected behavior:
- choose multiple media from library modal
- optional drag/drop ordering
- returns list compatible with new Doctrine media list type

### 3) Delete behavior integration
When media is deleted from the library:
- support existing delete strategies (`RESTRICT`, `SET_NULL`) for media lists too
- `SET_NULL`: remove matching path from the list
- `RESTRICT`: block deletion if path exists in at least one list field

## Example use case
A `Service` entity with:
- `heroImage` (single media)
- `galleryImages` (list of media paths)

In EasyAdmin, editors can add/remove/reorder gallery photos directly in one field without a dedicated join entity.

## Backward compatibility
- Keep existing single-media behavior unchanged
- Introduce feature as additive (new type/new option)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.