You are here

function imagefield_widget_settings_form in ImageField 6.3

Implementation of CCK's hook_widget_settings($op = 'form').

1 call to imagefield_widget_settings_form()
imagefield_widget_settings in ./imagefield.module
Implementation of CCK's hook_widget_settings().

File

./imagefield_widget.inc, line 11
ImageField widget hooks and callbacks.

Code

function imagefield_widget_settings_form($widget) {
  $form = module_invoke('filefield', 'widget_settings', 'form', $widget);
  if ($form['file_extensions']['#default_value'] == 'txt') {
    $form['file_extensions']['#default_value'] = 'png gif jpg jpeg';
  }
  $form['max_resolution'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum dimensions for images'),
    '#default_value' => !empty($widget['max_resolution']) ? $widget['max_resolution'] : 0,
    '#size' => 15,
    '#maxlength' => 10,
    '#description' => t('The maximum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction. If a larger image is uploaded, it will be resized to reflect the given width and height.'),
    '#weight' => 2.1,
  );
  $form['min_resolution'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum dimensions for images'),
    '#default_value' => !empty($widget['min_resolution']) ? $widget['min_resolution'] : 0,
    '#size' => 15,
    '#maxlength' => 10,
    '#description' => t('The minimum allowed image size expressed as WIDTHxHEIGHT (e.g. 640x480). Set to 0 for no restriction. If an image that is smaller than these dimensions is uploaded it will be rejected.'),
    '#weight' => 2.2,
  );
  if (!module_exists('imageapi') || imageapi_default_toolkit() == 'imageapi_gd') {
    $form['max_resolution']['#description'] .= ' ' . t('Resizing images on upload will cause the loss of <a href="http://en.wikipedia.org/wiki/Exchangeable_image_file_format">EXIF data</a> in the image.');
  }
  $form['alt_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('ALT text settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 8,
  );
  $form['alt_settings']['custom_alt'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable custom alternate text'),
    '#default_value' => !empty($widget['custom_alt']) ? $widget['custom_alt'] : 0,
    '#description' => t('Enable user input alternate text for images.'),
  );
  $form['alt_settings']['alt'] = array(
    '#type' => 'textfield',
    '#title' => t('Default ALT text'),
    '#default_value' => !empty($widget['alt']) ? $widget['alt'] : '',
    '#description' => t('This value will be used for alternate text by default.'),
    '#suffix' => theme('token_help', array(
      'user',
    )),
  );
  $form['title_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Title text settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 8,
  );
  $form['title_settings']['custom_title'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable custom title text'),
    '#default_value' => !empty($widget['custom_title']) ? $widget['custom_title'] : 0,
    '#description' => t('Enable user input title text for images.'),
  );
  $form['title_settings']['title_type'] = array(
    '#type' => 'select',
    '#title' => t('Input type'),
    '#options' => array(
      'textfield' => 'textfield',
      'textarea' => 'textarea',
    ),
    '#default_value' => !empty($widget['title_type']) ? $widget['title_type'] : 'textfield',
    '#description' => t('Choose type of field to be displayed to the user.'),
  );
  $form['title_settings']['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Default Title text'),
    '#default_value' => !empty($widget['title']) ? $widget['title'] : '',
    '#description' => t('This value will be used as the image title by default.'),
    '#suffix' => theme('token_help', array(
      'user',
    )),
  );

  // Default image settings.
  $form['default'] = array(
    '#type' => 'fieldset',
    '#title' => t('Default image'),
    '#element_validate' => array(
      '_imagefield_widget_settings_default_validate',
    ),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => 10,
  );

  // Present a thumbnail of the current default image.
  $form['default']['use_default_image'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use default image'),
    '#default_value' => $widget['use_default_image'],
    '#description' => t('When an image is not uploaded, show a default image on display.'),
  );
  if (!empty($widget['default_image'])) {
    $form['default']['default_image_thumbnail'] = array(
      '#type' => 'markup',
      '#value' => theme('imagefield_image', $widget['default_image'], '', '', array(
        'width' => '150',
      ), FALSE),
    );
  }
  $form['default']['default_image_upload'] = array(
    '#type' => 'file',
    '#title' => t('Upload image'),
    '#description' => t('Choose a image that will be used as default.'),
  );

  // We set this value on 'validate' so we can get CCK to add it
  // as a standard field setting.
  $form['default_image'] = array(
    '#type' => 'value',
    '#value' => $widget['default_image'],
  );
  return $form;
}