You are here

function imagemagick_imagemagick_post_save_alter in ImageMagick 8

Implements hook_imagemagick_post_save_alter().

File

./imagemagick.module, line 111
Provides ImageMagick integration.

Code

function imagemagick_imagemagick_post_save_alter(ImagemagickToolkit $toolkit) {
  $file_system = \Drupal::service('file_system');
  $destination = $toolkit
    ->getDestination();
  $path = $file_system
    ->realpath($destination);
  if (!$path) {

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