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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gulab.bisht created an issue. See original summary.

gbisht’s picture

Issue summary: View changes
marcoscano’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +D8Media

I 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!

ZeiP’s picture

I'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.

ZeiP’s picture

There's a similar issue for File Entity Browser.

ZeiP’s picture

Status: Postponed (maintainer needs more info) » Active

For 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.

ZeiP’s picture

Status: Active » Needs review
FileSize
857 bytes

Attached is a patch to check the entity type and fail more graciously.

cweagans’s picture

Status: Needs review » Needs work

I'm seeing this as well. The patch doesn't actually solve the problem, but it does make the problem more evident at least.

cweagans’s picture

Priority: Normal » Major

Also, bumping to major as this seems like a pretty key part of the module that's not working at all.

cweagans’s picture

Looks 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.

charly71’s picture

Same 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).

lhuria94’s picture

Having the same issue, anyone working on this or any update?

brandonratz’s picture

I 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...

Return source file entity
If checked, the source file(s) of the media entity will be returned from this widget.
jessey’s picture

FileSize
816 bytes