Drupal ajax error of undefined method getFileUri() while selecting newly uploaded image.

Created on 13 January 2017, almost 8 years ago
Updated 15 November 2023, about 1 year ago

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.

🐛 Bug report
Status

Needs work

Component

Widget plugins

Created by

🇭🇰Hong Kong gulab.bisht

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024