You are here

public function GDToolkitWebP::getRequirements in Picture 8

Gets toolkit requirements in a format suitable for hook_requirements().

Return value

array An associative requirements array as is returned by hook_requirements(). If the toolkit claims no requirements to the system, returns an empty array. The array can have arbitrary keys and they do not have to be prefixed by e.g. the module name or toolkit ID, as the system will make the keys globally unique.

Overrides GDToolkit::getRequirements

See also

hook_requirements()

File

src/Plugin/ImageToolkit/GDToolkitWebP.php, line 170
Contains \Drupal\system\Plugin\ImageToolkit\GDToolkit.

Class

GDToolkitWebP
Defines the GD2 toolkit for image manipulation within Drupal.

Namespace

Drupal\picture\Plugin\ImageToolkit

Code

public function getRequirements() {
  $requirements = array();
  $info = gd_info();
  $requirements['version'] = array(
    'title' => t('GD library'),
    'value' => $info['GD Version'],
  );

  // Check for filter and rotate support.
  if (!function_exists('imagefilter') || !function_exists('imagerotate')) {
    $requirements['version']['severity'] = REQUIREMENT_WARNING;
    $requirements['version']['description'] = t('The GD Library for PHP is enabled, but was compiled without support for functions used by the rotate and desaturate effects. It was probably compiled using the official GD libraries from http://www.libgd.org instead of the GD library bundled with PHP. You should recompile PHP --with-gd using the bundled GD library. See <a href="@url">the PHP manual</a>.', array(
      '@url' => 'http://www.php.net/manual/book.image.php',
    ));
  }
  elseif (version_compare(PHP_VERSION, '5.5.0') < 0) {
    $requirements['version']['severity'] = REQUIREMENT_ERROR;
    $requirements['version']['description'] = t('You need at least PHP version 5.5.0 to support WebP with the GD library. Your current PHP version is @version', array(
      '@version' => PHP_VERSION,
    ));
  }
  return $requirements;
}