function GDToolkit::checkAvifSupport
Checks if AVIF can encode image.
This method tries to create an AVIF image and save it to disk via imageavif(). If that fails, it's likely a codec missing, or the function was disabled. This is an expensive operation to run, so we cache its result.
Return value
bool TRUE if AVIF is fully supported, FALSE otherwise.
1 call to GDToolkit::checkAvifSupport()
- GDToolkit::getRequirements in core/
modules/ system/ src/ Plugin/ ImageToolkit/ GDToolkit.php - Gets toolkit requirements in a format suitable for hook_requirements().
File
-
core/
modules/ system/ src/ Plugin/ ImageToolkit/ GDToolkit.php, line 555
Class
- GDToolkit
- Defines the GD2 toolkit for image manipulation within Drupal.
Namespace
Drupal\system\Plugin\ImageToolkitCode
protected function checkAvifSupport() : bool {
static $supported = NULL;
if ($supported !== NULL) {
return $supported;
}
$tempFile = fopen('php://memory', 'r+');
$supported = imageavif(imagecreatetruecolor(1, 1), $tempFile, 0, 10) && fstat($tempFile)['size'] > 0;
fclose($tempFile);
return $supported;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.