You are here

function auto_image_style_field_formatter_settings_form in Auto image style 7

Implements hook_field_formatter_settings_form().

File

./auto_image_style.module, line 27

Code

function auto_image_style_field_formatter_settings_form($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $form = array();
  $options = image_style_options(FALSE, PASS_THROUGH);
  if (module_exists('picture')) {
    $options = array_merge($options, auto_image_style_picture_mapping_names());
    $form['picture_mapping_link'] = array(
      '#title' => t('Picture mapping'),
      '#type' => 'item',
      '#markup' => l(t('Create a picture mapping'), 'admin/config/media/picture/add'),
      '#description' => t('You can add new the Picture mapping and use it as image portrait or landscape style.'),
    );
  }
  else {
    $form['picture_mapping_link'] = array(
      '#type' => 'item',
      '#markup' => l(t('You also can use the Picture  module for output responsive images'), 'https://www.drupal.org/project/picture', array(
        'absolute' => TRUE,
        'attributes' => array(
          'title' => 'yadda, ydadda,yadda',
        ),
      )),
    );
  }
  $form['image_style_portrait'] = array(
    '#type' => 'select',
    '#title' => t('Select the portrait style'),
    '#options' => $options,
    '#empty_option' => t('None (original image)'),
    '#default_value' => $settings['image_style_portrait'],
    '#description' => t('Select the imagecache style for portrait images'),
  );
  $form['image_style_landscape'] = array(
    '#type' => 'select',
    '#title' => t('Select the landscape style'),
    '#options' => $options,
    '#empty_option' => t('None (original image)'),
    '#default_value' => $settings['image_style_landscape'],
    '#description' => t('Select the imagecache style for landscape images'),
  );
  $form['image_style_configure_css'] = array(
    '#type' => 'checkbox',
    '#title' => t('Configure CSS class'),
    '#default_value' => $settings['image_style_configure_css'],
  );
  $form['image_style_portrait_class'] = array(
    '#type' => 'textfield',
    '#title' => t('CSS Class for portrait'),
    '#default_value' => $settings['image_style_portrait_class'],
    '#size' => 60,
    '#maxlength' => 128,
    '#required' => TRUE,
    '#process' => array(
      '_auto_image_style_formatter_settings_form_process_add_state',
    ),
  );
  $form['image_style_landscape_class'] = array(
    '#type' => 'textfield',
    '#title' => t('CSS Class for landscape'),
    '#default_value' => $settings['image_style_landscape_class'],
    '#size' => 60,
    '#maxlength' => 128,
    '#required' => TRUE,
    '#process' => array(
      '_auto_image_style_formatter_settings_form_process_add_state',
    ),
  );
  $link_types = array(
    'content' => t('Content'),
    'file' => t('File'),
  );
  if (module_exists('link')) {
    $link_types = array_merge($link_types, auto_image_style_get_link_fields($instance));
  }
  $form['image_link'] = array(
    '#title' => t('Link image to'),
    '#type' => 'select',
    '#default_value' => $settings['image_link'],
    '#empty_option' => t('Nothing'),
    '#options' => $link_types,
  );
  return $form;
}