You are here

function youtube_field_formatter_settings_summary in YouTube Field 7

Implements hook_field_formatter_settings_summary().

File

./youtube.module, line 413

Code

function youtube_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];

  // Summary for the video style.
  if ($display['type'] == 'youtube_video') {
    $video_sizes = youtube_size_options();
    if (isset($video_sizes[$settings['youtube_size']])) {
      $summary = t('YouTube video: @size', array(
        '@size' => $video_sizes[$settings['youtube_size']],
      ));
    }
    else {
      $summary = t('YouTube video: 450px by 315px');
    }
    $parameters = array(
      $settings['youtube_autoplay'],
      $settings['youtube_mute'],
      $settings['youtube_loop'],
      $settings['youtube_controls'],
      $settings['youtube_autohide'],
      $settings['youtube_iv_load_policy'],
      $settings['youtube_playsinline'],
      $settings['youtube_allow_autoplay'],
      $settings['youtube_allow_fullscreen'],
    );
    foreach ($parameters as $parameter) {
      if ($parameter) {
        $summary .= t(', custom parameters');
        break;
      }
    }
    return $summary;
  }

  // Summary for the thumbnail style.
  if ($display['type'] == 'youtube_thumbnail') {
    $image_styles = image_style_options(FALSE);

    // Unset possible 'No defined styles' option.
    unset($image_styles['']);
    if (isset($image_styles[$settings['image_style']])) {
      $summary = t('Image style: @style.', array(
        '@style' => $image_styles[$settings['image_style']],
      ));
    }
    else {
      $summary = t('Original image.');
    }

    // Display this setting only if image is linked.
    $link_types = youtube_thumbnail_link_types();
    if (isset($settings['image_link']) && isset($link_types[$settings['image_link']])) {
      $summary .= '<br/>' . t('Linked to:') . ' ' . $link_types[$settings['image_link']] . '.';
    }
    return $summary;
  }

  // Summary for the URL style.
  if ($display['type'] == 'youtube_url') {
    $summary = t('YouTube URL');
    if (!empty($settings['link'])) {
      $summary .= ' ' . t('as a link.');
    }
    else {
      $summary .= ' ' . t('as plain text.');
    }
    return $summary;
  }
}