1.20.x system.module system_image_supported_extensions_alter(&$supported_extensions)

Implements hook_image_supported_extensions_alter().

Add webp to supported file extensions if GD is the active image toolkit and the GD version supports WebP.

File

modules/system/system.module, line 3824
Configuration system that lets administrators modify the workings of the site.

Code

function system_image_supported_extensions_alter(&$supported_extensions) {
  if (config_get('system.core', 'image_toolkit') == 'gd' && defined('IMAGETYPE_WEBP')) {
    $gd_info = gd_info();
    if (isset($gd_info['WebP Support']) && $gd_info['WebP Support'] == TRUE) {
      $supported_extensions[] = 'webp';
    }
  }
}