Support Media Library Media Modify reference fields

Created on 19 February 2024, about 1 year ago
Updated 20 August 2024, 8 months ago

Problem/Motivation

Media Library Media Modify β†’ provides an entity reference field with support for additional settings per reference.

It's essentially an extension of entity_reference field type so shouldn't be too hard.

Steps to reproduce

Proposed resolution

Add support for the field type entity_reference_entity_modify and see what happens.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs work

Version

5.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @imclean
  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    imclean β†’ changed the visibility of the branch 3422506-support-media-library-modify to hidden.

  • Merge request !120Update 3 files β†’ (Open) created by imclean
  • Status changed to Needs review about 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania
  • Pipeline finished with Success
    about 1 year ago
    Total: 266s
    #98964
  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    This works fine as a normal field formatter.

    Using Field block β†’ the target_bundles is missing (and possibly other field config settings).

    I can't tell which of the 3 modules is responsible.

  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    Fieldblock might be the problem. In its file src/Plugin/Block/FieldBlock.php there's a comment for getFieldDefinition():

       * A FieldBlock works on an entity type across bundles, and thus only has
       * access to field storage definitions. In order to be able to use formatters,
       * we create a generic field definition out of that storage definition.

    I think both the entity type and bundle are required to get additional config settings via entityFieldManager->getFieldDefinitions().

  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania
  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    The fieldblock issue in #7 also adds support for third party settings which is used by Photoswipe Dynamic Caption.

  • πŸ‡ΊπŸ‡¦Ukraine vlad.dancer Kyiv

    If you want to modify photoswipe formatter then you locked by #3301760.

  • Status changed to Needs work 8 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    I really dislike adding contrib module specific code. Any better approaches?

  • πŸ‡¦πŸ‡ΊAustralia imclean Tasmania

    I was following the existing pattern but yeah, I tend to agree.

    It might be better to rewrite it to check for Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem using is_a() or similar. Or if it implements Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItemInterface. But this might be tricky to do in annotations.

Production build 0.71.5 2024