You are here

function imageapi_optimize_services_tinypng_form in Image Optimize (or ImageAPI Optimize) 7

TinyPNG ImageAPI Optimize form callback.

File

services/tinypng.inc, line 22
tinypng API service integration.

Code

function imageapi_optimize_services_tinypng_form($info) {
  $form = array();
  $settings = variable_get('imageapi_optimize_tinypng', array(
    'api_key' => '',
    'debug_mode_tinypng' => FALSE,
  ));
  $form['imageapi_optimize_tinypng'] = array(
    '#type' => 'container',
    '#tree' => TRUE,
  );
  $form['imageapi_optimize_tinypng']['intro'] = array(
    '#markup' => t('<p>TinyPNG uses smart lossy compression techniques to reduce the file size of your PNG and JPEG files. By selectively decreasing the number of colors in the image, fewer bytes are required to store the data. The effect is nearly invisible but it makes a very large difference in file size!</p><p>TinyPNG compression ONLY APPLIES TO PNG and JPEG files. If your image is uploaded in other format, TinyPNG will not process the image and the default Image Toolkit processing will apply.</p><p>If you want to process existing PNG files, remove their image styles with the command <pre>drush image-flush --all</pre> and they will be recreated using TinyPNG the 1st time they are called.</p><p>Free licenses has a limit of conversions per user and per month. Please note that each time an image is uploaded to your Drupal site, an automatic request to TinyPNG is performed for EACH ONE of the Image Styles EFFECTIVELY USED for the image. This is the desired behavior, but it may quickly drain your monthly quota if many images are uploaded and many Image Styles are used.</p>'),
  );
  $form['imageapi_optimize_tinypng']['api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('TinyPNG API key'),
    '#default_value' => $settings['api_key'],
    '#size' => 33,
    '#maxlength' => 32,
    '#required' => FALSE,
    '#element_validate' => array(
      'imageapi_optimize_tinypng_validate_api_key',
    ),
  );
  $form['imageapi_optimize_tinypng']['debug_mode_tinypng'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable debug mode'),
    '#description' => t('Show statistics (size reduction) from successful requests as <a href="@url">log messages</a>.', array(
      '@url' => url('admin/reports/dblog'),
    )),
    '#default_value' => $settings['debug_mode_tinypng'],
  );
  return $form;
}