While uploading a new image and selecting it from "Upload" tab and click "Select files".
This is the error which come in the console.
An AJAX HTTP error occurred.↵HTTP Result Code: 200↵Debugging information follows.↵Path: /collageboard/docroot/node/add/media_wrapper?ajax_form=1↵StatusText: OK↵ResponseText: ↵( ! ) Fatal error: Call to undefined method Drupal\media_entity\Entity\Media::getFileUri() in /Users/gulab.bisht/Sites/collageboard/docroot/modules/contrib/entity_browser/src/Plugin/Field/FieldWidget/FileBrowserWidget.php on line 289
It seems like $entity on line 289 in FileBrowserWidget.php is generated from Drupal\media_entity\Entity\Media.php and this class doesn't have getFileUri().
Although image gets uploaded in the library.
On the other side if we select image from the library tab, then it works properly as in this situation $entity on line 289 gets generated from Drupal\file\Entity\File and this class got getFileUri().
For the image field widget is "Entity Browser" and "Image Browser" is the entity browser in the further settings.
Comment | File | Size | Author |
---|---|---|---|
#14 | 2843247-8.patch | 816 bytes | jessey |
#11 | Schermata 2018-03-09 alle 22.33.22.png | 60.12 KB | charly71 |
#7 | 2843247-7.patch | 857 bytes | ZeiP |
Comments
Comment #2
gbisht CreditAttribution: gbisht at Acquia commentedComment #3
marcoscanoI am unable to reproduce this problem with the current -dev version.
Could you please indicate if this issue still exists, and if so, provide detailed steps to reproduce it?
Thanks!
Comment #4
ZeiP CreditAttribution: ZeiP at Citrus Solutions Oy commentedI'm seeing this problem with the following configuration:
* Using a media reference field on a node form
* The entity browser has been configured to feature a Media Entity DropzoneJS or another widget that allows adding new media entities from the browser.
When I try to add a file to the browser and click Select files, I get a WSOD and the log has this exact error message. It seems that Entity browser assumes that the entity is a file, which it is not. I'm not sure if it's more my configuration's fault or if this should work and it's a bug.
Comment #5
ZeiP CreditAttribution: ZeiP at Citrus Solutions Oy commentedThere's a similar issue for File Entity Browser.
Comment #6
ZeiP CreditAttribution: ZeiP at Citrus Solutions Oy commentedFor me this was fixed by defining the entity type to Media in the Selection display tab of the Entity browser configuration. I think there should be a better error message for having a wrong kind of entity in the selection.
Comment #7
ZeiP CreditAttribution: ZeiP at Citrus Solutions Oy commentedAttached is a patch to check the entity type and fail more graciously.
Comment #8
cweagansI'm seeing this as well. The patch doesn't actually solve the problem, but it does make the problem more evident at least.
Comment #9
cweagansAlso, bumping to major as this seems like a pretty key part of the module that's not working at all.
Comment #10
cweagansLooks like the problem here is mostly a UI problem. An image field will let me configure an Entity Browser as the form widget, but if I select a Media entity in that browser (even if the actual file is an image), I get this error. The media field version works as expected, but also requires me to use a separate view mode for displaying the entity in the selection list, rather than just selecting an image style inline in the configuration for the form widget.
Not really sure how you want to solve this problem, but if you have ideas, I'm open to working on this for the next couple days.
Comment #11
charly71 CreditAttribution: charly71 commentedSame issue for me... with 8.x-1.4 version and 8.x-2.0-dev version:
Error: Call to undefined method Drupal\media\Entity\Media::getFileUri() in Drupal\entity_browser\Plugin\EntityBrowser\FieldWidgetDisplay\ImageThumbnail->view() (line 70 of /Applications/MAMP/htdocs/dd85/modules/contrib/entity_browser/src/Plugin/EntityBrowser/FieldWidgetDisplay/ImageThumbnail.php)
I've opened my installation folder with PHPStorm and it shows me the error without run the code (see the image attached).
Comment #12
lhuria94 CreditAttribution: lhuria94 at Srijan | A Material+ Company commentedHaving the same issue, anyone working on this or any update?
Comment #13
brandonratz CreditAttribution: brandonratz as a volunteer commentedI just hit this same error when trying to use a File Upload widget for an image field. The widget doesn't return the file uri correctly because its technically the media entity. If you check the "Return source file entity" box you should get the expected functionality.
Must check the box...
Comment #14
jessey CreditAttribution: jessey commented