You are here

public function ImageReplaceEffect::applyEffect in Image Replace 8

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/ImageReplaceEffect.php, line 65

Class

ImageReplaceEffect
Rotates an image resource.

Namespace

Drupal\image_replace\Plugin\ImageEffect

Code

public function applyEffect(ImageInterface $image) {
  $configuration = $this
    ->getConfiguration();
  $replacement_file = $this->imageReplaceStorage
    ->get($configuration['data']['image_style'], $image
    ->getSource());
  if ($replacement_file) {
    $toolkit_id = $image
      ->getToolkitId();
    $replacement_image = $this->imageFactory
      ->get($replacement_file, $toolkit_id);
    if ($replacement_image) {
      $image
        ->apply('image_replace', [
        'replacement_image' => $replacement_image,
      ]);
    }
  }
}