You are here

protected function Scale::execute in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Scale::execute()

Performs the actual manipulation on the image.

Image toolkit operation implementers must implement this method. This method is responsible for actually performing the operation on the image. When this method gets called, the implementer may assume all arguments, also the optional ones, to be available, validated and corrected.

Parameters

array $arguments: An associative array of arguments to be used by the toolkit operation.

Return value

bool TRUE if the operation was performed successfully, FALSE otherwise.

Overrides Resize::execute

File

core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Scale.php, line 81

Class

Scale
Defines GD2 Scale operation.

Namespace

Drupal\system\Plugin\ImageToolkit\Operation\gd

Code

protected function execute(array $arguments = []) {

  // Don't scale if we don't change the dimensions at all.
  if ($arguments['width'] !== $this
    ->getToolkit()
    ->getWidth() || $arguments['height'] !== $this
    ->getToolkit()
    ->getHeight()) {

    // Don't upscale if the option isn't enabled.
    if ($arguments['upscale'] || $arguments['width'] <= $this
      ->getToolkit()
      ->getWidth() && $arguments['height'] <= $this
      ->getToolkit()
      ->getHeight()) {
      return parent::execute($arguments);
    }
  }
  return TRUE;
}