Hi,
I'm hoping someone might be able to help me with this. I'd like users to be able to select from the media library (instead of the images just being saved as a file that can't be reused). I've gotten this to work within the ckeditor, but can't seem to get it to work within an image field. I can get it to show the browser and pick an image - I'm getting a "The website encountered an unexpected error. Please try again later." I'm attaching a few images to show what I'm getting.

I'll also note that I'm pretty new to drupal in general, so I could possibly just be missing something simple.

Comments

riverwaters created an issue. See original summary.

cxc891’s picture

A little off topic but think this as an alternative:
If the goal is to re-use images in wysiwyg, I would just use IMCE...
If the goal is also to re-use them in an image or file field, you can try the 'file field sources' module.

louisnagtegaal’s picture

I'm having exactly the same problem (adding the error as text, and not as an image so that it shows up in the issue search results).

TypeError: Argument 1 passed to file_validate() must implement interface Drupal\file\FileInterface, instance of Drupal\media_entity\Entity\Media given, called in /var/www/mysite/docroot/modules/contrib/entity_browser/src/Plugin/EntityBrowser/WidgetValidation/File.php on line 31 in file_validate() (regel 286 van /var/www/mysite/docroot/core/modules/file/file.module) 
#0 /var/www/mysite/docroot/modules/contrib/entity_browser/src/Plugin/EntityBrowser/WidgetValidation/File.php(31): file_validate(Object(Drupal\media_entity\Entity\Media), Array) 
#1 /var/www/mysite/docroot/modules/contrib/entity_browser/src/WidgetBase.php(319): Drupal\entity_browser\Plugin\EntityBrowser\WidgetValidation\File->validate(Array, Array) 
#2 /var/www/mysite/docroot/modules/contrib/entity_browser/src/WidgetBase.php(294): Drupal\entity_browser\WidgetBase->runWidgetValidators(Array, Array) 
#3 /var/www/mysite/docroot/modules/contrib/dropzonejs/modules/eb_widget/src/Plugin/EntityBrowser/Widget/DropzoneJsEbWidget.php(251): Drupal\entity_browser\WidgetBase->validate(Array, Object(Drupal\Core\Form\FormState)) 
#4 /var/www/mysite/docroot/modules/contrib/entity_browser/src/Form/EntityBrowserForm.php(171): Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\DropzoneJsEbWidget->validate(Array, Object(Drupal\Core\Form\FormState)) 
#5 [internal function]: Drupal\entity_browser\Form\EntityBrowserForm->validateForm(Array, Object(Drupal\Core\Form\FormState)) 
#6 /var/www/mysite/docroot/core/lib/Drupal/Core/Form/FormValidator.php(83): call_user_func_array(Array, Array) 
#7 /var/www/mysite/docroot/core/lib/Drupal/Core/Form/FormValidator.php(270): Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object(Drupal\Core\Form\FormState)) 
#8 /var/www/mysite/docroot/core/lib/Drupal/Core/Form/FormValidator.php(119): Drupal\Core\Form\FormValidator->doValidateForm(Array, Object(Drupal\Core\Form\FormState), 'entity_browser_...') 
#9 /var/www/mysite/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(571): Drupal\Core\Form\FormValidator->validateForm('entity_browser_...', Array, Object(Drupal\Core\Form\FormState)) 
#10 /var/www/mysite/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(314): Drupal\Core\Form\FormBuilder->processForm('entity_browser_...', Array, Object(Drupal\Core\Form\FormState)) 
#11 /var/www/mysite/docroot/core/lib/Drupal/Core/Controller/FormController.php(74): Drupal\Core\Form\FormBuilder->buildForm('entity_browser_...', Object(Drupal\Core\Form\FormState)) 
#12 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch)) 
#13 /var/www/mysite/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array) 
#14 /var/www/mysite/docroot/core/lib/Drupal/Core/Render/Renderer.php(574): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 
#15 /var/www/mysite/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure)) 
#16 /var/www/mysite/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) 
#17 [internal function]: Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() 
#18 /var/www/mysite/vendor/symfony/http-kernel/HttpKernel.php(144): call_user_func_array(Object(Closure), Array) 
#19 /var/www/mysite/vendor/symfony/http-kernel/HttpKernel.php(64): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1) 
#20 /var/www/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#21 /var/www/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#22 /var/www/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#23 /var/www/mysite/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#24 /var/www/mysite/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#25 /var/www/mysite/docroot/core/lib/Drupal/Core/DrupalKernel.php(656): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true) 
#26 /var/www/mysite/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request)) 
#27 {main}.
riverwaters’s picture

I was able to figure this out only as an entity reference, where I reference media and then can use the media embed. I still can't get this to work with an image field.