Hi there,

Sorry if this is in the wrong place.

Upon installation of Media + Entity browser I get the following when trying to upload a file in the modal view. Have tried using Entity Browser 1.0 and the dev branch, on different machines. All have the exact same issue.

Steps:

  1. drush en media
  2. Create an empty content type 'Test'
  3. Add an Image reference field
  4. Set form display type to Entity Browser with the Gallery Media library option selected
  5. Create a new Test content item and hit the Select Media button on the image reference field
  6. In the modal, click the upload images tab and select an image to upload
  7. Press select entities and immediately get the below error in the modal
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to file_validate() must implement interface Drupal\file\FileInterface, instance of Drupal\media_entity\Entity\Media given, called in /path/to/drupal/modules/contrib/entity_browser/src/Plugin/EntityBrowser/WidgetValidation/File.php on line 31 in file_validate() (line 286 of core/modules/file/file.module).
file_validate(Object, Array) (Line: 31)
Drupal\entity_browser\Plugin\EntityBrowser\WidgetValidation\File->validate(Array, Array) (Line: 319)
Drupal\entity_browser\WidgetBase->runWidgetValidators(Array, Array) (Line: 294)
Drupal\entity_browser\WidgetBase->validate(Array, Object) (Line: 251)
Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\DropzoneJsEbWidget->validate(Array, Object) (Line: 171)
Drupal\entity_browser\Form\EntityBrowserForm->validateForm(Array, Object)
call_user_func_array(Array, Array) (Line: 83)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 270)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'entity_browser_gallery_media_library_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('entity_browser_gallery_media_library_form', Array, Object) (Line: 571)
Drupal\Core\Form\FormBuilder->processForm('entity_browser_gallery_media_library_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('entity_browser_gallery_media_library_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
CommentFileSizeAuthor
#5 drupal-capture.png17.59 KBhdotnet

Comments

hdotnet created an issue. See original summary.

achraffessi’s picture

I have the same problem,
any solution please ?

stijndmd’s picture

@hdonet: have you tried this with the previous (8.x-1.0-rc2) version as well?

stijndmd’s picture

You need to add a Media reference field of type: image, instead of a image reference field.

hdotnet’s picture

StatusFileSize
new17.59 KB

The add new field drop down doesn't contain any image entries under the Media option group:

Screen capture of add a new field drop down.

stijndmd’s picture

You need to add a reference field instead.

Reference group => Other
Next step: Content group => Media
Next step: in the field setup you can pick one of your created media bundles.

remyyyyy’s picture

@stijndmd thank u !!

remyyyyy’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

pancho’s picture

This might possibly be a Won't fix, however most certainly it is not fixed, and new similar issues have been opened.
Would someone please mark this a duplicate of #2930677: Validate widget entity type and bundles, because I can't. Thanks!

oknate’s picture

Status: Closed (fixed) » Closed (duplicate)