You are here

public function AdvanceResizeImageEffect::applyEffect in image effect 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/ImageEffect/AdvanceResizeImageEffect.php \Drupal\image_effect\Plugin\ImageEffect\AdvanceResizeImageEffect::applyEffect()
  2. 1.0.x src/Plugin/ImageEffect/AdvanceResizeImageEffect.php \Drupal\image_effect\Plugin\ImageEffect\AdvanceResizeImageEffect::applyEffect()

Applies an image effect to the image object.

Parameters

\Drupal\Core\Image\ImageInterface $image: An image file object.

Return value

bool TRUE on success. FALSE if unable to perform the image effect on the image.

Overrides ImageEffectInterface::applyEffect

File

src/Plugin/ImageEffect/AdvanceResizeImageEffect.php, line 23

Class

AdvanceResizeImageEffect
Resizes an image resource in advance.

Namespace

Drupal\image_effect\Plugin\ImageEffect

Code

public function applyEffect(ImageInterface $image) {
  if (!$image
    ->apply('advance_resize', [
    'width' => $this->configuration['width'],
    'height' => $this->configuration['height'],
  ])) {
    $this->logger
      ->error('Image adavance resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', [
      '%toolkit' => $image
        ->getToolkitId(),
      '%path' => $image
        ->getSource(),
      '%mimetype' => $image
        ->getMimeType(),
      '%dimensions' => $image
        ->getWidth() . 'x' . $image
        ->getHeight(),
    ]);
    return FALSE;
  }
  return TRUE;
}