Skip to content

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

@BriceFab

Description

@BriceFab

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<Media|string> or list<Media> (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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions