Needs work
Project:
Entity Browser
Version:
8.x-1.x-dev
Component:
Widget plugins
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
26 Oct 2016 at 15:47 UTC
Updated:
25 Mar 2019 at 16:23 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #2
anpolimusComment #3
anpolimusComment #4
anpolimusComment #5
marcoscanoCould you please provide more detailed steps on how to reproduce the error?
(Specially which modules are used, and what configuration is in the entity browsers. I cannot find any "Entity browser image" module, so I'm not quite sure how to reproduce your scenario).
Also, it could be helpful if you could provide an export of your entity browser configuration, if you know how to do so :) (on development -> synchronization -> export -> single item)
Comment #6
anpolimusHi.
I'm installing lightning profile at the simlpytest.me project.
Comment #7
anpolimusI'll provide more detailed test case soon
Comment #8
slashrsm commentedComment #9
Jonah Fenn commentedI've run into a similar problem as well. @anpolimums, I'm assuming that you're trying to upload media into an image or file field (this was the case for me). These fields need a file entity type.
A media field is actually an entity reference - this isn't really very clearly documented yet. Here's how you add the field to your node types:
When adding a new field that will contain media types, in the Entity Reference section, select "Other" and then make your media specific configurations on the screens that follow.
I've attached a screenshot to help clarify. I hope it helps you out.
Comment #10
anpolimusHi, that was mostly configuration problem
@fenns is right - I was trying to upload image to the file field that is not media entity.
This issue could be closed.
Comment #11
anpolimusComment #12
lpeabody commentedI just ran into this while trying to upload new files in a CKEditor wysiwyg. Specifically I get the "The entity must be of type media." error.
Comment #13
lpeabody commentedComment #14
slashrsm commentedAs it was already mentioned #10 this shows that there is probably some mis-configuration. It is your responsibility to understand entities of which type will be provided by the widgets that are used on the Entity browser. The type of the entities returned from the widgets should match the type that is expected from the calling code.
It would be nice to have automatic checking for that, but that would be very hard to do with the current architecture that is trying not to assume anything about the type.
Comment #15
vlad.dancer@slashrsm
Completely agree and I think this is quite easy to achive, we need just "field instance" context inside widgets, see below.
@anpolimus despite of that fact that this is a field widget configuration question
actualy we could improve expirience using of Entity Browser (EB).
We might want to restrict running of particular EB widget if widget designed to work only with images or pdf files for instance.
All that we need is to get "field" context to extract target entity type bundles.
It would be nice to extend
\Drupal\entity_browser\WidgetInterface,and add something like
isApplicable($field_instance)method to decide if a current field supports image files for instance.But there is no "field" context neither inside a WidgetBase nor inside an EntityBrowserForm.
Actually there is basic support of "widget context" inside
\Drupal\entity_browser\Form\EntityBrowserForm::initvia
$form_state->set(['entity_browser', 'widget_context'], []);We used form_state in IntelligenceBank DAM Connector project to add desired context via hook_field_widget_WIDGET_TYPE_form_alter
and later inside our EB widget to make decision what kind of media types we can create for current media reference field:
real example
For me having an "isApplicable" method inside WidgetInterface - looks like this is very usefull to to allow widget to make decision on runtime if it could be used in current context.
What do you think guys?
Comment #16
oknateI'm working on validation for the widgets against the target entity type, see #2930677: Validate widget entity type and bundles.
Comment #17
oknateI have been working validating the widgets in the related issue #2930677: Validate widget entity type and bundles. Reopening to see if I can drum up a review.