I created a field with the default Image Bundle. When I create content and try to upload an image it gives the following error: The media bundle is not configured correctly.

In Drupal\entity_browser\Plugin\EntityBrowser\Widget\Upload:getForm() $this->configuration['media bundle'] is always NULL.

If I temporally replace:

   if (!$this->configuration['media bundle'] || !($bundle = $this->entityManager->getStorage('media_bundle')->load($this->configuration['media bundle']))) {
      return ['#markup' => $this->t('The media bundle is not configured correctly.')];
    }

With:

if (!$bundle = $this->entityManager->getStorage('media_bundle')->load('image'))) {
      return ['#markup' => $this->t('The media bundle is not configured correctly.')];
    }

It works. I temporally hardcoded 'image' since that is my media bundle name just to see if it works.

I guess $this->configuration['media bundle'] will never get a value because the media bundle isn't handled on the Entity Browser but on the field level.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

albertski created an issue. See original summary.

albertski’s picture

Issue summary: View changes
slashrsm’s picture

Category: Bug report » Support request

You are probably using \Drupal\media_entity_image\Plugin\EntityBrowser\Widget\Upload here. This entity browser widget needs to be configured correctly. One of the most important parts of the configuration is the bundle that will be used when creating media entities from uploaded files. Please check entity browser's config UI for more info (admin/config/content/entity_browser).

slashrsm’s picture

Category: Support request » Bug report
Status: Active » Needs review
Issue tags: +Needs tests

There is a problem with the configuration form indeed. This patch should fix it while also improving UX.

This patch still needs update hook and tests. Please apply the patch, recreate the entity browser and let me know if it fixed your problem.

slashrsm’s picture

FileSize
3.74 KB

And the patch.

albertski’s picture

Status: Needs review » Reviewed & tested by the community

This patch looks good and it fixed the "The media bundle is not configured correctly" issue.

slashrsm’s picture

Status: Reviewed & tested by the community » Needs work

Great. Thank you for your feedback. We still need tests.

thenchev’s picture

Status: Needs work » Needs review
FileSize
5.42 KB
9.16 KB

Working on test coverage. These are the steps I did:
1. Created a media bundle with type provider "image" and added an image field.
2. Created an entity browser and on the last step "Widgets" added the "Upload images" and set up the correct bundle (created before).
3. When opening the media browser i get this:
User error: "0" is an invalid render array key in Drupal\Core\Render\Element::children() (line 97 of core/lib/Drupal/Core/Render/Element.php).
4. Also when i upload an image and select it, nothing appears.

Test is not 100% done but we first need to fix the error.

thenchev’s picture

Fixed the error. The upload extensions validation was not working because of that. Created a followup for the tests #2728839: Extension validation tests

Status: Needs review » Needs work

The last submitted patch, 9: the_media_bundle_is_not-2721793-9.patch, failed testing.

The last submitted patch, 9: the_media_bundle_is_not-2721793-9.patch, failed testing.

thenchev’s picture

i guess we need this first.

Status: Needs review » Needs work

The last submitted patch, 12: the_media_bundle_is_not-2721793-12.patch, failed testing.

The last submitted patch, 12: the_media_bundle_is_not-2721793-12.patch, failed testing.

  • slashrsm committed 487d5ea on 8.x-1.x authored by Denchev
    Issue #2721793 by Denchev, slashrsm: Add test dependency.
    
thenchev’s picture

this should be green.

  • slashrsm committed b032464 on 8.x-1.x authored by Denchev
    Issue #2721793 by Denchev, slashrsm: The media bundle is not configured...
slashrsm’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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

slashrsm’s picture

Issue tags: +D8Media