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.
Comment | File | Size | Author |
---|---|---|---|
#16 | the_media_bundle_is_not-2721793-16.patch | 9.83 KB | thenchev |
#16 | interdiff-2721793-16.txt | 475 bytes | thenchev |
#12 | the_media_bundle_is_not-2721793-12.patch | 304 bytes | thenchev |
#9 | the_media_bundle_is_not-2721793-9.patch | 9.87 KB | thenchev |
#9 | interdiff-2721793-9.txt | 1.44 KB | thenchev |
Comments
Comment #2
albertski CreditAttribution: albertski as a volunteer and commentedComment #3
slashrsm CreditAttribution: slashrsm at MD Systems GmbH for Acquia commentedYou 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).
Comment #4
slashrsm CreditAttribution: slashrsm at MD Systems GmbH for Acquia commentedThere 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.
Comment #5
slashrsm CreditAttribution: slashrsm at MD Systems GmbH for Acquia commentedAnd the patch.
Comment #6
albertski CreditAttribution: albertski commentedThis patch looks good and it fixed the "The media bundle is not configured correctly" issue.
Comment #7
slashrsm CreditAttribution: slashrsm at MD Systems GmbH for Acquia commentedGreat. Thank you for your feedback. We still need tests.
Comment #8
thenchev CreditAttribution: thenchev at MD Systems GmbH for Acquia commentedWorking 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.
Comment #9
thenchev CreditAttribution: thenchev at MD Systems GmbH for Acquia commentedFixed the error. The upload extensions validation was not working because of that. Created a followup for the tests #2728839: Extension validation tests
Comment #12
thenchev CreditAttribution: thenchev at MD Systems GmbH for Acquia commentedi guess we need this first.
Comment #16
thenchev CreditAttribution: thenchev at MD Systems GmbH for Acquia commentedthis should be green.
Comment #18
slashrsm CreditAttribution: slashrsm at MD Systems GmbH for Acquia commentedCommitted.
Comment #20
slashrsm CreditAttribution: slashrsm at MD Systems GmbH for Acquia commented