Problem/Motivation

Focal Point used to work fine with the dropzonejs module and media library, but with #3341846: Set custom form id for media library form 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

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

JeffM2001 created an issue. See original summary.

serkanb’s picture

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?

jeffm2001’s picture

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.

ltrain’s picture

This works for me using focal_point 2.0.

nickrhymes’s picture

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);
}
lefteous’s picture

Any chance of this getting a dev review and merge?
The proposed hook does work well but we're hesitant to add it into a custom module at this point if it can be added into this project.
We have 1000+ sites that this change would be great for.

jeffm2001’s picture

Status: Active » Reviewed & tested by the community

We've been using this fix for 2 years now without issue.

bleen made their first commit to this issue’s fork.

rajeshreeputra’s picture

Status: Reviewed & tested by the community » Fixed

MR merged!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

markconroy’s picture

Thanks for getting this merged, would it be possible to get a new release of Focal Point so people can start using it?

justcaldwell’s picture

Yes, please. +1 to tagging a new release.