You are here

function bootstrap_carousel_if_field_formatter_settings_form in Bootstrap Carousel Image Formatter 7.3

Implements hook_field_formatter_settings_form().

File

./bootstrap_carousel_if.module, line 152
Bootstrap Carousel Image Field.

Code

function bootstrap_carousel_if_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $settings = $instance['display'][$view_mode]['settings'];
  $options = array();
  $element['interval'] = array(
    '#title' => t('Interval'),
    '#type' => 'textfield',
    '#default_value' => $settings['interval'],
    '#required' => TRUE,
  );
  $element['pause'] = array(
    '#title' => t('Pause on hover'),
    '#type' => 'select',
    '#options' => array(
      0 => 'no',
      'hover' => 'yes',
    ),
    '#default_value' => $settings['pause'],
  );
  $element['wrap'] = array(
    '#title' => t('Wrap'),
    '#type' => 'select',
    '#options' => array(
      0 => 'no',
      1 => 'yes',
    ),
    '#default_value' => $settings['wrap'],
  );
  $element['keyboard'] = array(
    '#title' => t('Keyboard'),
    '#type' => 'select',
    '#options' => array(
      0 => 'no',
      1 => 'yes',
    ),
    '#default_value' => $settings['keyboard'],
  );
  $element['indicators'] = array(
    '#title' => t('Indicators'),
    '#type' => 'select',
    '#options' => array(
      0 => 'no',
      1 => 'yes',
    ),
    '#default_value' => $settings['indicators'],
  );

  // Get image styles
  $styles = image_styles();
  $options = array(
    0 => 'Original image',
  );
  foreach ($styles as $key => $value) {
    $options[$key] = $value['label'];
  }
  $element['image_style'] = array(
    '#title' => t('Image style'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => $settings['image_style'],
  );
  $element['background'] = array(
    '#title' => t('Force all image to appear same size (css background images)'),
    '#type' => 'select',
    '#prefix' => '<div id="bootstrap-carousel-bg-setting">',
    '#suffix' => '</div>',
    '#options' => array(
      0 => 'no',
      1 => 'yes',
    ),
    '#default_value' => $settings['background'],
    '#description' => '<div style="white-space: pre-line">' . t('Setting this to yes makes the images a background image of a div, rather than an image tag. Background position "cover" is set so the image always fills the space. This may cause some parts of the image to not be visible and it will also upscale your images if it is not large enough. You can set the height and width of the div below, or leave them blank and do it in your own CSS. Either way, atleast the height needs to be set on the div so the image is visible.') . '</div>',
  );
  $element['background_pos'] = array(
    '#title' => t('Background position'),
    '#type' => 'select',
    '#options' => array(
      'left top' => 'left top',
      'left center' => 'left top',
      'left bottom' => 'left bottom',
      'right top' => 'right top',
      'right center' => 'right center',
      'right bottom' => 'right bottom',
      'center top' => 'center top',
      'center center' => 'center center',
      'center bottom' => 'center bottom',
    ),
    '#default_value' => $settings['background_pos'],
    '#states' => array(
      'invisible' => array(
        '#bootstrap-carousel-bg-setting select' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  $element['width'] = array(
    '#title' => t('Width'),
    '#type' => 'textfield',
    '#default_value' => $settings['width'],
    '#description' => '<div style="white-space: pre-line">' . t('Only takes effect when background setting is on. expected values are something like "100%" or "100px". Set this value to an empty string to use values from your own CSS.') . '</div>',
    '#states' => array(
      'invisible' => array(
        '#bootstrap-carousel-bg-setting select' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  $element['height'] = array(
    '#title' => t('Height'),
    '#type' => 'textfield',
    '#default_value' => $settings['height'],
    '#description' => '<div style="white-space: pre-line">' . t('Only takes effect when background setting is on. expected values are something like "100%" or "100px". Set this value to an empty string to use values from your own CSS.') . '</div>',
    '#states' => array(
      'invisible' => array(
        '#bootstrap-carousel-bg-setting select' => array(
          'value' => 0,
        ),
      ),
    ),
  );
  return $element;
}