Container data return

Last updated on
30 April 2025

For modules which implement container functionality (the ability to create a list of files for a user to select from), data needs to be handed back to the Media module in a specific format to populate the Media browser correctly.

<?php

/**
 * Implementation of hook_media_user_files_select
 *
 * @param string $node_type
 *   drupal node type
 * @param string $field
 *   field name that is being overridden
 * @param int $uid
 *   user id
 */
function media_upload_media_user_files_select($node_type, $field, $uid) {
  return array(
    t('Add files') => array(
      t('New file') => media_upload_display_upload_form(),
    )
  );
}
?>

The format for this data return is the tab name, drawer or sub-element name, and the form to be displayed when the drawer is active. Media will merge modules which use the same tab name together, creating a list of drawers for that tab. Modules need to be responsible for name space collisions.

Help improve this page

Page status: Not set

You can: