Compatibility with DropzoneJS

Created on 24 February 2023, over 1 year ago
Updated 27 October 2023, about 1 year ago

Problem/Motivation

Focal Point used to work fine with the dropzonejs module and media library, but with πŸ› Set custom form id for media library form Fixed they changed the form id, and as a result, focal_point_form_media_library_add_form_upload_alter is no longer triggered.

Steps to reproduce

Proposed resolution

Change the hook to alter the base form id media_library_add_form and add any additional checks that are needed.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Media Integration

Created by

πŸ‡ΊπŸ‡ΈUnited States jeffm2001

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

Comments & Activities

  • Issue created by @jeffm2001
  • πŸ‡©πŸ‡ͺGermany SerkanB

    The easiest fix would be to implement the form_alter with the new ID and call the old form_alter...

    function focal_point_form_media_library_add_form_dropzonejs_alter(array &$form, FormStateInterface $form_state) {
      focal_point_form_media_library_add_form_upload_alter($form, $form_state);
    }
    

    But this feels wrong, having some hook of a random contrib module. Is this the way to go?

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    158 pass
  • @serkanb opened merge request.
  • πŸ‡ΊπŸ‡ΈUnited States jeffm2001

    Having a hook that alters the media_library_add_form_dropzonejs form is not really any different than altering the media_library_add_form_upload form. I just did it this way in order to not repeat code.

    Perhaps it would look less weird if it was changed to a hook_form_alter() with a condition to check the form ids inside the function.

  • πŸ‡¨πŸ‡¦Canada laura.j.johnson@gmail.com Toronto

    This works for me using focal_point 2.0.

  • πŸ‡¬πŸ‡§United Kingdom nickrhymes

    Am seeing this issue with focal_point 2.0.2

    Putting the suggestion from #2 in to a custom module resolves the issue for me as a workaround until fixed properly.
    e.g.

    function MODULE_NAME_form_media_library_add_form_dropzonejs_alter(array &$form, \Drupal\Core\Form\FormStateInterface $form_state) {
      focal_point_form_media_library_add_form_upload_alter($form, $form_state);
    }
    
Production build 0.71.5 2024