class ReplaceImage in Image Effects 8
Same name in this branch
- 8 src/Plugin/ImageToolkit/Operation/gd/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\ReplaceImage
- 8 src/Plugin/ImageToolkit/Operation/imagemagick/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ReplaceImage
Same name and namespace in other branches
- 8.3 src/Plugin/ImageToolkit/Operation/imagemagick/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ReplaceImage
- 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/ReplaceImage.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ReplaceImage
Defines Imagemagick image replace operation.
Plugin annotation
@ImageToolkitOperation(
id = "image_effects_imagemagick_replace_image",
toolkit = "imagemagick",
operation = "replace_image",
label = @Translation("Replace image"),
description = @Translation("Replace the current image with another one.")
)
Hierarchy
- class \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\ReplaceImage extends \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\ImagemagickImageToolkitOperationBase uses ReplaceImageTrait
Expanded class hierarchy of ReplaceImage
File
- src/
Plugin/ ImageToolkit/ Operation/ imagemagick/ ReplaceImage.php, line 19
Namespace
Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagickView source
class ReplaceImage extends ImagemagickImageToolkitOperationBase {
use ReplaceImageTrait;
/**
* {@inheritdoc}
*/
protected function execute(array $arguments) {
$replacement = $arguments['replacement_image'];
// Replacement image local path.
$local_path = $replacement
->getToolkit()
->getSourceLocalPath();
if ($local_path === '') {
$source_path = $replacement
->getToolkit()
->getSource();
throw new \InvalidArgumentException("Missing local path for image at {$source_path}");
}
$this
->getToolkit()
->resetArguments()
->setSourceLocalPath($replacement
->getToolkit()
->getSourceLocalPath())
->setSourceFormat($replacement
->getToolkit()
->getSourceFormat())
->setExifOrientation($replacement
->getToolkit()
->getExifOrientation())
->setWidth($replacement
->getWidth())
->setHeight($replacement
->getHeight());
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ReplaceImage:: |
protected | function | ||
ReplaceImageTrait:: |
protected | function | ||
ReplaceImageTrait:: |
protected | function |