Skip to content

Feature request: optional media metadata persistence (alt, caption, copyright, tags) #90

Open

Description

@BriceFab

Summary

Support an optional metadata layer for media (alt, caption, copyright, tags) in JoliMediaBundle.

Context / use-case

In real websites, media are not only file paths: editors need reusable metadata for SEO/L+JSON and editorial quality:

  • alt text
  • caption / legend
  • copyright / credits
  • tags / categorization

Typical example: gallery photos attached to pages, services, or products.

Today, JoliMedia stores media as filesystem paths and Doctrine media / media_long fields in entities. This works well for storage and transformations, but there is no native place to store reusable editorial metadata per media.

Current workaround

Projects must create a custom entity layer (e.g. MediaAsset, ServiceGalleryImage) to map media paths and metadata, then maintain custom forms, synchronization, and deletion behavior.

Proposal

Introduce an optional metadata persistence model in the bundle (or a bridge package), for example:

  • MediaRecord (path, library, alt, caption, copyright, tags, createdAt, updatedAt)

Potential integrations:

  1. Resolver API to fetch metadata from path.
  2. EasyAdmin media library UI to edit metadata.
  3. Twig helpers/components to render alt/caption fallback from metadata.
  4. Move/delete listeners to keep metadata rows consistent with media path changes.

Additional benefit: safer deletion when media is linked

With a metadata/entity layer, the bundle could also provide native usage checks before deletion, for example:

  • prevent deleting a media if it is linked to one or more entities (RESTRICT behavior)
  • show where it is used before confirming deletion
  • optionally offer SET_NULL / detach strategies depending on configuration

This would make media management safer for editors and avoid broken content after accidental deletes.

Why this matters

  • Better accessibility and SEO at scale.
  • Reusable metadata across pages/components.
  • Less custom boilerplate in each project.

Activity

  1. charliefancelli commented on Oct 23, 2026

    @charliefancelli
    Contributor

    Hello, and thank you for this bundle.

    I am currently implementing this feature on a fork, and I would like to propose it as a pull request. Before opening it, I would appreciate your feedback on the following design.

    Opt-in configuration. A new joli_media.metadata section, disabled by default. When disabled, the bundle behaves exactly as today and requires no additional dependency.

    Storage. Metadata is accessed through a MetadataStorageInterface. A Doctrine ORM implementation would be shipped, storing one record per library and path, with alt, caption, copyright and tags. Other storages, such as a sidecar file on Flysystem, could be added later behind the same interface.

    Rendering. New Twig filters in the existing extension (joli_media_alt, joli_media_caption, joli_media_copyright, joli_media_tags). The Img and Picture components would use the stored alternative text when no alt attribute is provided; an explicit alt, including an empty one for decorative images, always takes precedence.

    Administration. In the EasyAdmin bridge, a metadata form on the media detail page, an indicator for images without alternative text, and a tag filter in the media list.

    Consistency. Metadata follows moves and renames, and is removed with the media, within the existing move and delete listeners.

    Usages. Optionally, and possibly as a separate pull request: listing where a media is used, based on the MediaType columns found in the Doctrine mapping and on a MediaUsageProviderInterface for other references, and displaying these usages when a deletion is refused.

    This first contribution would only cover the EasyAdmin bridge. The core (storage, Twig filters, listeners) would remain bridge-agnostic, so that the Sonata and Sylius bridges could build on it later. I am of course open to adjusting naming, scope and structure to fit the project’s conventions.

  2. damienalexandre commented on Oct 30, 2026

    @damienalexandre
    Member

    I would like a feature like this as well.

    The MetadataStorageInterface looks good 👍

  3. BriceFab commented on Oct 31, 2026

    @BriceFab
    ContributorAuthor

    Thanks for working on this! I’ve implemented a similar layer on top of JoliMedia with Doctrine entities, stable IDs, metadata, tags, EasyAdmin integration and reference tracking.

    The opt-in architecture and MetadataStorageInterface look good.

    A few points to consider:

    • Referential integrity: handle moves, renames and replacements without breaking metadata associations.
    • Usage tracking: support Doctrine media / media_long fields and extensible references via MediaUsageProviderInterface.
    • Deletion guard: enforce RESTRICT at the core level, independently of EasyAdmin.

    I agree that usage tracking could be a separate PR to keep the initial scope focused.

    Happy to review the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions