You are here

function theme_media_widget in D7 Media 7.4

Same name and namespace in other branches
  1. 7.2 includes/media.fields.inc \theme_media_widget()
  2. 7.3 includes/media.fields.inc \theme_media_widget()

Returns HTML for an individual media widget.

Parameters

array $variables: An associative array containing:

  • element: A render element representing the widget.
1 theme call to theme_media_widget()
media_element_info in ./media.module
Implements hook_element_info().

File

includes/media.fields.inc, line 495
Provide media selector widget and media field formatters to the fields API.

Code

function theme_media_widget($variables) {
  $element = $variables['element'];
  $output = '';

  // Merge provided attributes with existing ones.
  // The "form-media" class is required for proper Ajax functionality.
  $attributes = array(
    'class' => array(
      "media-widget",
      "form-media",
      "clearfix",
    ),
  );
  if (!empty($element['#attributes'])) {
    $attributes = array_merge_recursive($attributes, $element['#attributes']);
  }
  if (!empty($element['#id'])) {
    $attributes = array_merge_recursive($attributes, array(
      'id' => $element['#id'] . '--widget',
    ));
  }

  // Render attributes into div in one go.
  $output .= '<div ' . drupal_attributes($attributes) . '>';
  $output .= drupal_render_children($element);
  $output .= '</div>';
  return $output;
}