You are here

function textimage_field_formatter_settings_form in Textimage 7.3

Implements hook_field_formatter_settings_form().

File

./textimage.module, line 439
Textimage - Provides text to image manipulations.

Code

function textimage_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];

  // Image style setting.
  $image_styles = TextimageStyles::getOptions(FALSE);
  $element['image_style'] = array(
    '#title' => t('Image style'),
    '#type' => 'select',
    '#default_value' => $settings['image_style'],
    '#options' => $image_styles,
    '#required' => TRUE,
    '#description' => t('Only Textimage relevant image styles can be selected.'),
  );

  // Multi-value text field image generation settings.
  if ($field['module'] == 'text' && $field['cardinality'] != 1) {
    $options = array(
      'merge' => t("Build one single image, styling together text values."),
      'itemize' => t("Build multiple images, styling each text value in a separate image."),
    );
    $element['image_text_values'] = array(
      '#title' => t('Multiple values text field'),
      '#type' => 'radios',
      '#default_value' => $settings['image_text_values'],
      '#options' => $options,
      '#required' => TRUE,
      '#description' => t("Text values are styled following the sequence of 'Textimage text' effects in the image style."),
    );
  }

  // Link setting.
  $link_types = array(
    'content' => t('Content'),
    'file' => t('File'),
  );
  $element['image_link'] = array(
    '#title' => t('Link image to'),
    '#type' => 'select',
    '#default_value' => $settings['image_link'],
    '#empty_option' => t('Nothing'),
    '#options' => $link_types,
  );

  // Image alt and title attribute settings.
  $element['image_alt'] = array(
    '#title' => t('Alternate text'),
    '#type' => 'textfield',
    '#default_value' => $settings['image_alt'],
    '#description' => t('This text will be used by screen readers, search engines, or when the image cannot be loaded.') . ' ' . t('Tokens can be used.'),
    '#maxlength' => 512,
  );
  $element['image_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $settings['image_title'],
    '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.') . ' ' . t('Tokens can be used.'),
    '#maxlength' => 1024,
  );
  return $element;
}