You are here

function imagecache_requirements in ImageCache 5

Same name and namespace in other branches
  1. 5.2 imagecache.install \imagecache_requirements()
  2. 6.2 imagecache.install \imagecache_requirements()

Implementation of hook_requirements().

File

./imagecache.module, line 55
Dynamic image resizer and image cacher.

Code

function imagecache_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {

    // Clean URLS.
    if (!variable_get('clean_url', 0)) {
      $requirements['clean_urls'] = array(
        'title' => $t('Clean URLs'),
        'value' => $t('Not enabled'),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('Imagecache will not operate properly if <a href="!url">Clean URLs</a> is not enabled on your site.', array(
          '!url' => url('admin/settings/clean-urls'),
        )),
      );
    }

    // Check for an image library.
    if (count(image_get_available_toolkits()) == 0) {
      $requirements['image_toolkits'] = array(
        'title' => $t('Image Toolkit'),
        'value' => $t('No image toolkits available'),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('Imagecache requires an imagetoolkit such as <a href="http://php.net/gd">GD2</a> or <a href="http://www.imagemagick.org">Imagemagick</a> be installed on your server.'),
      );
    }

    // Check for public files.
    if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PRIVATE) {
      $requirements['file_system'] = array(
        'title' => $t('File Download Method'),
        'value' => $t('Private Downloads'),
        'severity' => REQUIREMENT_ERROR,
        'description' => $t('Imagecache will not operate properly using Private Files. Please enable <a href="!url">Public File Transfer</a>.', array(
          '!url' => url('admin/settings/file-system'),
        )),
      );
    }

    // Check for JPEG/PNG/GIF support.
    if ('gd' == image_get_toolkit()) {
      foreach (array(
        'gif',
        'jpeg',
        'png',
      ) as $format) {
        if (!function_exists('imagecreatefrom' . $format)) {
          $requirements['gd_' . $format] = array(
            'title' => $t('GD !format Support', array(
              '!format' => drupal_ucfirst($format),
            )),
            'value' => $t('Not installed'),
            'severity' => REQUIREMENT_INFO,
            'description' => $t('PHP was not compiled with %format support. Imagecache will not be able to process %format images.', array(
              '%format' => $format,
            )),
          );
        }
      }
    }
  }
  return $requirements;
}