You are here

function amp_field_formatter_settings_summary in Accelerated Mobile Pages (AMP) 7

Implements hook_field_formatter_settings_summary().

File

./amp.module, line 1063

Code

function amp_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();
  if (strpos($display['type'], '_trimmed') !== FALSE) {
    $summary[] = t('Trimmed limit: @trim_length characters', array(
      '@trim_length' => $settings['trim_length'],
    ));
  }
  if (strpos($display['type'], 'amp_video') !== FALSE) {
    $summary[] = t('Dimensions for aspect ratio: @width' . 'px x @height' . 'px', array(
      '@width' => $settings['amp_video_width'],
      '@height' => $settings['amp_video_height'],
    ));
  }
  if (strpos($display['type'], 'amp_image') !== FALSE) {
    $image_styles = image_style_options(FALSE, PASS_THROUGH);

    // Unset possible 'No defined styles' option.
    unset($image_styles['']);

    // Styles could be lost because of enabled/disabled modules that defines
    // their styles in code.
    if (isset($image_styles[$settings['image_style']])) {
      $summary[] = t('Image style: @style', array(
        '@style' => $image_styles[$settings['image_style']],
      ));
    }
    else {
      $summary[] = t('Original image');
    }
    $link_types = array(
      'content' => t('Linked to content'),
      'file' => t('Linked to file'),
    );

    // Display this setting only if image is linked.
    if (isset($link_types[$settings['image_link']])) {
      $summary[] = $link_types[$settings['image_link']];
    }
    $layout_options = _amp_get_layouts();
    $layout_setting = $settings['amp_layout'];
    if (isset($layout_options[$layout_setting])) {
      $summary[] = t('Layout: @setting', array(
        '@setting' => $layout_options[$layout_setting],
      ));
      if ($layout_options[$layout_setting] === 'fixed-height') {
        $summary[] = t('Fixed height: @height', array(
          '@height' => $settings['amp_fixed_height'],
        ));
      }
    }
  }
  return implode('<br />', $summary);
}