function AvifImageEffect::applyEffect

Overrides ConvertImageEffect::applyEffect

File

core/modules/image/src/Plugin/ImageEffect/AvifImageEffect.php, line 43

Class

AvifImageEffect
Converts an image resource to AVIF, with fallback.

Namespace

Drupal\image\Plugin\ImageEffect

Code

public function applyEffect(ImageInterface $image) {
    // If avif is not supported fallback to the parent.
    if (!$this->isAvifSupported()) {
        return parent::applyEffect($image);
    }
    if (!$image->convert('avif')) {
        $this->logger
            ->error('Image convert failed using the %toolkit toolkit on %path (%mimetype)', [
            '%toolkit' => $image->getToolkitId(),
            '%path' => $image->getSource(),
            '%mimetype' => $image->getMimeType(),
        ]);
        return FALSE;
    }
    return TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.