You are here

public function GDToolkit::getRequirements in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::getRequirements()

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 ImageToolkitBase::getRequirements

See also

hook_requirements()

File

core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php, line 391

Class

GDToolkit
Defines the GD2 toolkit for image manipulation within Drupal.

Namespace

Drupal\system\Plugin\ImageToolkit

Code

public function getRequirements() {
  $requirements = [];
  $info = gd_info();
  $requirements['version'] = [
    '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="http://php.net/manual/book.image.php">the PHP manual</a>.');
  }
  return $requirements;
}