You are here

public function ImagemagickEventSubscriber::postSave in ImageMagick 8.2

Same name and namespace in other branches
  1. 8.3 src/EventSubscriber/ImagemagickEventSubscriber.php \Drupal\imagemagick\EventSubscriber\ImagemagickEventSubscriber::postSave()

Reacts to an image save.

Alters an image after it has been converted by the ImageMagick toolkit.

ImageMagick does not support remote file systems, so modules can decide to move temporary files from the local file system to remote destination systems.

Parameters

\Drupal\imagemagick\Event\ImagemagickExecutionEvent $event: Imagemagick execution event.

See also

\Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::save()

\Drupal\imagemagick\ImagemagickExecArguments::getDestination()

\Drupal\imagemagick\ImagemagickExecArguments::getDestinationLocalPath()

File

src/EventSubscriber/ImagemagickEventSubscriber.php, line 207

Class

ImagemagickEventSubscriber
Imagemagick's module Event Subscriber.

Namespace

Drupal\imagemagick\EventSubscriber

Code

public function postSave(ImagemagickExecutionEvent $event) {
  $arguments = $event
    ->getExecArguments();
  $destination = $arguments
    ->getDestination();
  if (!$this->fileSystem
    ->realpath($destination)) {

    // We are working with a remote file, so move the temp file to the final
    // destination, replacing any existing file with the same name.
    file_unmanaged_move($arguments
      ->getDestinationLocalPath(), $arguments
      ->getDestination(), FILE_EXISTS_REPLACE);
  }
}