Call to undefined function media_browser_js()

meshbrains's picture
meshbrains
Sun, 07/26/2015 - 20:04
#1
Call to undefined function media_browser_js()

On a fresh install of D7, latest media module (7.x-2.0-beta1) and latest md_megamenu, got a blank screen after adding a new MDMegaMenu, saving, and then editing. Apache log revealed the following: 

PHP Fatal error:  Call to undefined function media_browser_js() in /var/www/commerce/sites/all/modules/md_megamenu/includes/md_megamenu.utils.inc on line 627, referer: http://shop.norbest.com/admin/structure/md-megamenu

Traced to a change in media module 7.x-2.0-beta1, "the media browser settings were "simplified" and moved to a library which makes the media_attach_browser_js() and media_browser_js() helper functions unnecessary, since they require more code and the loading of a file, compared to simply attaching the library."

To correct this, open includes/md_megamenu.utils.inc, line 626 and replace:

  module_load_include('inc', 'media', 'includes/media.browser');
  $javascript = media_browser_js();
  foreach ($javascript as $key => $definitions) {
    foreach ($definitions as $definition) {
      $function = 'drupal_add_' . $key;
      call_user_func_array($function, $definition);
    }
  }

with

  drupal_add_library('media', 'media_browser');
  drupal_add_library('media', 'media_browser_settings');

Hope that helps someone...

phuonght's picture
phuonght
Sun, 07/26/2015 - 22:48

Hi,

Thank you for your feedback.

It will help other customers and us so much. If you have any problem when using mega menu in the future, please feel free to tell us.

Isaac's picture
Isaac
Mon, 09/07/2015 - 18:46

I've noticed this problem on MD Alpine as well.  Fatal error: Call to undefined function media_browser_js() drupal. This fixed by modding sites/all/modules/custom/md_fullscreen_slider/inc/md_fullscreen_slider.utils.inc as follows:

Original Becomes:

Fixed

Thanks to MeshBrains for the snippet.

ludwigpossie's picture
ludwigpossie
Thu, 09/24/2015 - 14:32

Meshbrains;

Thanks for the tip.  Helped me out!

LP

eevensen's picture
eevensen
Thu, 11/12/2015 - 18:44

Please send me the update to solve the media module 7.x-2.0-beta1 issues as well. Thanks in advance.

phuonght's picture
phuonght
Thu, 11/12/2015 - 22:12

Hi Eevensen,

We checked and could not see your purchase code of Mega menu. Please go to your account page (http://megadrupal.com/user/eevensen) to add your purchase code for updated files and more supports.

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.