Source: https://jimbir.ch/blog/changing-order-drupal-7-media-module-file-browser-tabs/

[Back to blog](https://jimbir.ch/blog) Drupal 7

# Changing the Order of Drupal 7 Media Module File Browser Tabs

By Jim Birch Jan 1, 2016 2 min read

![Changing the Order of Drupal 7 Media Module File Browser Tabs](https://jimbir.ch/assets/blog/changing-order-drupal-7-media-module-file-browser-tabs.avif)

I am working on a site where the client requested that the Library tab be the first tab in the Media module’s File browser pop up. While this is a seemingly simple request, it is one that I have never run into.

I looked at the views, and in devel themer and at a bit of the module code. I searched on the googles, the issue queues and the stack overflows, but could not find a solution. After posting in the #drupal-media IRC channel, [Brandon Neil](https://twitter.com/brandonneil) came to the rescue pointing me towards [hook\_media\_browser\_plugin\_info\_alter()](http://www.drupalcontrib.org/api/drupal/contributions!media!media.api.php/function/hook_media_browser_plugin_info_alter/7)

Here is the original order of the file browser. In order to change the order and hook into this function, I created a simple custom module, **mediamenu**. In this module, I will be able to hook into the media module using the hook Brandon showed me, and change the weight of the tabs, re-ordering them. The module has a folder named **mediamenu** , and inside two files, named **mediamenu.info** and **mediamenu.module**. You can view and download these files from [this github repo](https://github.com/xenomedia/mediamenu).

## mediamenu.info

The .info file contains information about the module, name, description, version, which version of Drupal, and where to group it on the modules page.

```
name = Media Menu
description = This module organizes the tabs on the Media browser.
version = "7.x-1.0"
core = "7.x"
package = Media
```

## mediamenu.module

In the .module file, we hook in and change the weights of the tabs, which will re-order them, the heaviest weight/lowest number first.

The first two items here are provided by the Media module, and the Media Browser view (Machine name: media\_default). The two tabs are made by the two displays of the view, media\_browser\_1 and  
media\_browser\_my\_files. The media\_internet tab is provided by the module of the same name. Upload is provided by the media module.

```
< ?php
/**
 * Change Order of Media Browser Tabs
 *
 * Implements hook_media_browser_plugin_info_alter().
 */
function mediamenu_media_browser_plugin_info_alter(&$info) {
  $info['media_default--media_browser_1']['weight'] = '-10';
  $info['media_default--media_browser_my_files']['weight'] = '-9';
  $info['media_internet']['weight'] = '-8';
  $info['upload']['weight'] = '-7';
}

```

You may have additional tabs provided by other modules. You can find their machine name but looking at the source markup of the page, and looking for the data-tabid of the tab.

## In conclusion

Once you have created or recreated these two files, in a folder called mediamenu, upload it to your site and enable it in the UI or **drush en -y mediamenu**. Clear the caches and you should see your changes the next time you open the File browser.

[View the discussion thread.](http://jimbirch.disqus.com/?url=https%3A%2F%2Fjimbir.ch%2Fblog%2Fchanging-order-drupal-7-media-module-file-browser-tabs)
