You are here

function brightcove_field_formatter_settings_summary in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.module \brightcove_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary().

Parameters

$field:

$instance:

$view_mode:

Return value

array|null|string

File

./brightcove.module, line 535
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function brightcove_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = '';
  if ($display['type'] == 'brightcove_default') {
    $summary = t('Size: @width x @height', [
      '@width' => $settings['width'],
      '@height' => $settings['height'],
    ]);
  }
  if ($display['type'] == 'brightcove_image') {
    $image_styles = image_style_options(FALSE);

    // Unset possible 'No defined styles' option.
    unset($image_styles['']);
    if (isset($image_styles[$settings['brightcove_image_style']])) {
      $summary = t('Image style: @style', [
        '@style' => $image_styles[$settings['brightcove_image_style']],
      ]);
    }
    else {
      $summary = t('Original image');
    }
  }
  if ($display['type'] == 'brightcove_metadata') {
    $metadata_options = _brightcove_field_get_object_formatter_keys();
    if (isset($settings['brightcove_metadata_type'])) {
      $summary = t('Metadata: @metadata', [
        '@metadata' => $metadata_options[$settings['brightcove_metadata_type']],
      ]);
    }
    else {
      $summary = t('Metadata: @metadata', [
        '@metadata' => reset($metadata_options),
      ]);
    }
  }
  return $summary;
}