You are here

function imageapi_optimize_settings_form in Image Optimize (or ImageAPI Optimize) 6

Settings form for the toolkit.

File

./imageapi_optimize.module, line 40
Image optimize functionalities

Code

function imageapi_optimize_settings_form() {
  $toolkits = array();
  foreach (imageapi_get_available_toolkits() as $toolkit => $info) {
    if ($toolkit != 'imageapi_optimize') {
      $toolkits[$toolkit] = $info['name'];
    }
  }
  $form['imageapi_optimize_basic'] = array(
    '#type' => 'fieldset',
    '#title' => t('Basic settings'),
  );
  $form['imageapi_optimize_basic']['imageapi_optimize_toolkit'] = array(
    '#type' => 'radios',
    '#title' => t('Base toolkit'),
    '#default_value' => variable_get('imageapi_optimize_toolkit', imageapi_default_toolkit()),
    '#options' => $toolkits,
    '#element_validate' => array(
      'imageapi_optimize_toolkit_element_validate',
    ),
  );
  $services = array(
    'internal' => 'Internal tools (configurable below)',
    'smushit' => 'Yahoo! Smush.It',
  );
  $form['imageapi_optimize_basic']['imageapi_optimize_service'] = array(
    '#type' => 'radios',
    '#title' => t('Choose which optimization service to use'),
    '#default_value' => variable_get('imageapi_optimize_service', 'internal'),
    '#options' => $services,
  );
  $form['imageapi_optimize_internal'] = array(
    '#type' => 'fieldset',
    '#title' => t('Paths to internal tools'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('imageapi_optimize_service', 'internal') !== 'internal',
  );
  $form['imageapi_optimize_internal']['imageapi_optimize_advpng'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to advpng'),
    '#default_value' => variable_get('imageapi_optimize_advpng', ''),
    '#element_validate' => array(
      'imageapi_optimize_validate_path',
    ),
    '#description' => t('Leave empty to skip this command. You can download it <a href="!link">here</a> (part of AdvanceCOMP).', array(
      '!link' => 'http://advancemame.sourceforge.net/comp-download.html',
    )),
  );
  $form['imageapi_optimize_internal']['imageapi_optimize_optipng'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to optipng'),
    '#default_value' => variable_get('imageapi_optimize_optipng', ''),
    '#element_validate' => array(
      'imageapi_optimize_validate_path',
    ),
    '#description' => t('Leave empty to skip this command. You can download it <a href="!link">here</a>.', array(
      '!link' => 'http://optipng.sourceforge.net/',
    )),
  );
  $form['imageapi_optimize_internal']['imageapi_optimize_pngcrush'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to pngcrush'),
    '#default_value' => variable_get('imageapi_optimize_pngcrush', ''),
    '#element_validate' => array(
      'imageapi_optimize_validate_path',
    ),
    '#description' => t('Leave empty to skip this command. You can download it <a href="!link">here</a>.', array(
      '!link' => 'http://pmt.sourceforge.net/pngcrush/',
    )),
  );
  $form['imageapi_optimize_internal']['imageapi_optimize_jpegtran'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to jpegtran'),
    '#default_value' => variable_get('imageapi_optimize_jpegtran', '/usr/bin/jpegtran'),
    '#element_validate' => array(
      'imageapi_optimize_validate_path',
    ),
    '#description' => t('Leave empty to skip this command. This is a part of <a href="!link">libjpeg</a> and could probably on your system.', array(
      '!link' => 'http://ijg.org/',
    )),
  );
  $form['imageapi_optimize_internal']['imageapi_optimize_jfifremove'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to jfifremove'),
    '#default_value' => variable_get('imageapi_optimize_jfifremove', ''),
    '#element_validate' => array(
      'imageapi_optimize_validate_path',
    ),
    '#description' => t('Leave empty to skip this command. You can download it <a href="!link">here</a>.', array(
      '!link' => 'http://lyncd.com/files/imgopt/jfifremove.c',
    )),
  );

  // Reloads methods because user may change toolkit
  $form['#submit'][] = '_imageapi_optimize_get_methods';
  return system_settings_form($form);
}