0

Is it possible to change the default tab for Media browser (Media module) in Drupal 7? Currently I have: Upload, Web, Library and My Files.

I would like to open Library by default, instead of Upload.

1 Answer 1

0

This is what you are looking for:

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

I just tried and it works perfect:

Blockquote

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.