When using the layout builder module and having an add media widget as a field in an inline-block type the selected media, when picked from the media library, does not attach to the field.

I can upload and insert an image, and works as expected. The error occurs when trying to insert the selected image submit button is pressed.

It fails silently with no errors in dblog or form error inline errors.

This error only occurred after updating from 8.6 to 8.7.

Issue fork drupal-3081319

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

TheLostCookie created an issue. See original summary.

jfortune’s picture

I have found that in MediaLibrarySelectForm::updateWidget method that $field_id was giving back zero $selcted_ids. I made a patch that will check the "media_library_select_form" and if it exist then add them to $selected_ids.

cilefen’s picture

Version: 8.7.7 » 8.8.x-dev
Status: Active » Needs review
cilefen’s picture

Status: Needs review » Needs work

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

dmitry.korhov’s picture

Applied patch for latest 8.8.1 release

dmitry.korhov’s picture

Status: Needs work » Needs review
dmitry.korhov’s picture

Version: 8.9.x-dev » 8.8.x-dev

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

phenaproxima’s picture

Is there any chance of us getting some steps to reproduce this bug, ideally on a clean installation of Drupal?

phenaproxima’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Media Initiative, +Triaged Media Initiative issue, +Bug Smash Initiative

I think that this will, at a minimum, need automated test coverage. Marking as "needs work" for that.

colepacak’s picture

@JFortune, your patch from #2 worked great for Drupal 8.9.9. I really appreciate it.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
joshua1234511’s picture

Tried to replicate the issue, Tested on v 9.4.0
- Steps Followed
-- Enabled layout builder.
-- Edit the block type and added a field with media embed widget.
-- Adding new image or selecting of image and insert works as intended.

Issue detected when No image is selected and insert image is clicked, It does not display the error on the form, but logs it ind blogs.

Issue
Issue
Issue

kristen pol’s picture

Version: 9.3.x-dev » 9.4.x-dev

Thanks for testing. Needs work to fix the issue noted.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

awset’s picture

hi all,

in regards @joshua1234511 comment #16
I think https://www.drupal.org/project/drupal/issues/3167799 will solve this issue.
the solution in that issue is to disable the button if no media is selected.

have a look at the comment #49
it has a video demonstrated the disabled button when no item selected.

but unfortunately, the original issue posted here is still mystery for me,
the OP said "The error occurs when trying to insert the selected image submit button is pressed."
this means OP did select an image but it silently fail?

if possible can we get the step to replicate it in D9.5?

thanks.

joshua1234511’s picture

Thank you @awset for providing the related issue.
The original issue has been fixed and tested in patch #6

The issue I reported is related to Media library widget counter does not reset when removing and re-adding media

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adriancotter’s picture

I am getting this error, Inserting an Image into an media field --within a nested paragraph (a paragraph within a paragraph) -- choosing from the media library. The error only occurs when the view has been filtered. If the user just chooses an image from the first screen, the error does not occur.

It works fine (choosing a filtered image) when the media field is on the page, and when the media field is in an unnested paragraph.

The error displayed to the user is (if they close the media library and scroll to the top -- otherwise it just looks like nothing happens)
"Oops, something went wrong. Check your browser's developer console for more details."

In the console I see:
Drupal.AjaxError {message: '\nAn AJAX HTTP error occurred

Digging into the AJAX code there is a parser error, though I've not been able to figure out what the actual error problem is with parsing.

The context url is media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=image&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_media%3A-field_paragraphs-0-subform-field_card-0-subform&media_library_opener_parameters%5Bentity_type_id%5D=paragraph&media_library_opener_parameters%5Bbundle%5D=somebundle&media_library_opener_parameters%5Bfield_name%5D=field_media&media_library_opener_parameters%5Bentity_id%5D=271207&media_library_opener_parameters%5Brevision_id%5D=472632&hash=...&name=vol&label=Some%20Label&sort_by=created&ajax_form=1&views_display_id=widget&_wrapper_format=drupal_ajax

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

mayurgajar’s picture

Added PR: https://git.drupalcode.org/project/drupal/-/merge_requests/14305

Steps to replicate issue:
1. On layout builder
2. Edit any content like block
3. In that for media -> select media image and image not selected
4. this will add error in logs

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.