You are here

imageapi_optimize.install in Image Optimize (or ImageAPI Optimize) 7

Install, update and uninstall functions.

File

imageapi_optimize.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions.
 */

/**
 * Implements hook_uninstall().
 */
function imageapi_optimize_uninstall() {
  db_delete('variable')
    ->condition('name', db_like('imageapi_optimize_') . '%', "LIKE")
    ->execute();
  cache_clear_all('variables', 'cache_bootstrap');
}

/**
 * Upgrade variables.
 */
function imageapi_optimize_update_7000() {
  $variable_names = array(
    'imageapi_optimize_advpng',
    'imageapi_optimize_optipng',
    'imageapi_optimize_jpegtran',
    'imageapi_optimize_jfifremove',
    'imageapi_optimize_pngcrush',
  );
  foreach ($variable_names as $variable_name) {
    $value = variable_get($variable_name, '');
    variable_del($variable_name);
    if (!empty($value)) {
      variable_set($variable_name, array(
        'status' => TRUE,
        'path' => $value,
      ));
    }
  }
  drupal_flush_all_caches();
}

/**
 * If imageapi_optimize_service is set to 'smushit', change it to 'resmushit'.
 */
function imageapi_optimize_update_7001() {
  $var = variable_get('imageapi_optimize_service');
  if ($var == 'smushit') {
    variable_set('imageapi_optimize_service', 'resmushit');
  }
}

Functions

Namesort descending Description
imageapi_optimize_uninstall Implements hook_uninstall().
imageapi_optimize_update_7000 Upgrade variables.
imageapi_optimize_update_7001 If imageapi_optimize_service is set to 'smushit', change it to 'resmushit'.