You are here

function jw_player_field_formatter_settings_summary in JW Player 7.2

Same name and namespace in other branches
  1. 7 jw_player.module \jw_player_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary().

File

./jw_player.module, line 296
Adds a theme function which allows theme developers to use the JW Player.

Code

function jw_player_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();
  if (isset($settings['jwplayer_preset'])) {
    $preset_settings = jw_player_preset_settings($settings['jwplayer_preset']);

    // Formatted preset name and player type.
    $summary[] = $preset_settings['name'];
    if (isset($settings['player_type'])) {
      $player = drupal_ucfirst($settings['player_type']);
      $summary[] = t('Type: @player_type', array(
        '@player_type' => $player,
      ));
    }
    if (stripos($preset_settings['source'], 'drupal') !== FALSE) {

      // Skin, dimensions, enabled options, and sharing sites.
      if (isset($preset_settings['skin'])) {
        $summary[] = $preset_settings['skin'];
      }
      $summary[] = $preset_settings['dimensions'];
      if (isset($preset_settings['enabled'])) {
        $summary[] = $preset_settings['enabled'];
      }
      if (isset($preset_settings['sharing'])) {
        $summary[] = $preset_settings['sharing'];
      }
    }
    else {
      $summary[] = $preset_settings['source'];
    }

    // Preview image settings.
    if (isset($settings['preview_image_field']) && !empty($settings['preview_image_field'])) {

      // Get image field label.
      $split = explode('|', $settings['preview_image_field']);
      $info = field_info_instance($instance['entity_type'], $split[1], $instance['bundle']);

      // Get image style label.
      if (!empty($settings['preview_image_style'])) {
        $styles = image_styles();
        $preview_image_style = $styles[$settings['preview_image_style']]['label'];
      }
      else {
        $preview_image_style = 'Original';
      }
      $summary[] = t('Preview: @field (@style)', array(
        '@field' => $info['label'],
        '@style' => $preview_image_style,
      ));
    }
  }
  else {
    $summary[] = t('No preset selected');
  }
  if ($display['type'] == 'jw_player_playlist') {
    $playlist_size = $settings['playlist_size'] . 'px';
    $summary[] = t('Playlist size: @val', array(
      '@val' => $playlist_size,
    ));
    $summary[] = t('Playlist position: @val', array(
      '@val' => $settings['playlist_position'],
    ));
  }
  return implode('<br />', $summary);
}