You are here

function file_entity_file_formatter_file_image_settings in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.module \file_entity_file_formatter_file_image_settings()
  2. 7 file_entity.module \file_entity_file_formatter_file_image_settings()

Implements hook_file_formatter_FORMATTER_settings().

Returns form elements for configuring the 'file_image' formatter.

1 string reference to 'file_entity_file_formatter_file_image_settings'
file_entity_file_formatter_info in ./file_entity.module
Implements hook_file_formatter_info().

File

./file_entity.module, line 1411
Extends Drupal file entities to be fieldable and viewable.

Code

function file_entity_file_formatter_file_image_settings($form, &$form_state, $settings) {
  $element = array();
  $element['image_style'] = array(
    '#title' => t('Image style'),
    '#type' => 'select',
    '#options' => image_style_options(FALSE),
    '#default_value' => $settings['image_style'],
    '#empty_option' => t('None (original image)'),
  );

  // For image files we allow the alt attribute (required in HTML).
  $element['alt'] = array(
    '#title' => t('Alt attribute'),
    '#description' => t('The text to use as value for the <em>img</em> tag <em>alt</em> attribute.'),
    '#type' => 'textfield',
    '#default_value' => $settings['alt'],
  );

  // Allow the setting of the title attribute.
  $element['title'] = array(
    '#title' => t('Title attribute'),
    '#description' => t('The text to use as value for the <em>img</em> tag <em>title</em> attribute.'),
    '#type' => 'textfield',
    '#default_value' => $settings['title'],
  );
  if (module_exists('token')) {
    $element['alt']['#description'] .= t('This field supports tokens.');
    $element['title']['#description'] .= t('This field supports tokens.');
    $element['tokens'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        'file',
      ),
      '#dialog' => TRUE,
    );
  }
  return $element;
}