Call to undefined function media_browser_js()

rodryg's picture
rodryg
Mon, 09/07/2015 - 16:15
#1
Call to undefined function media_browser_js()

Hi,

When try to edit the 'Demo slider' on 'Structure/MD FullScreen Sliders' this happens:

Fatal error: Call to undefined function media_browser_js() in sites/all/modules/custom/md_fullscreen_slider/inc/md_fullscreen_slider.utils.inc on line 442

Thank you for your help,

Rodrigo.

Isaac's picture
Isaac
Mon, 09/07/2015 - 21:03

I've noticed this problem on MD Alpine as well. "Fatal error: Call to undefined function media_browser_js() drupal." This is fixed by modding ./sites/all/modules/custom/md_fullscreen_slider/inc/md_fullscreen_slider.utils.inc as follows, and you can open the enclosed screenshots fullsize for clarity:

Original

http://files.megadrupal.com/forum/1723/[email protected]

 Becomes:

Fixed

http://files.megadrupal.com/forum/1723/[email protected]

Thanks to MeshBrains for the snippet. You can see his more detailed explanation below or the original comment here:

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
Mon, 09/07/2015 - 22:53

Hi Issac, 

Thank you for you detailed feedback. It will help us and other customers so much. If there is any problem when using our theme in the future, please feel free to tell us.

----

Hi Rodryg,

Could you try to fix problem following Issac's instruction and check if it works?

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.