You are here

public function PDFPreviewGenerator::updatePDFPreview in PDFPreview 8

Same name and namespace in other branches
  1. 2.0.x src/PdfPreviewGenerator.php \Drupal\pdfpreview\PdfPreviewGenerator::updatePdfPreview()

Deletes the preview image for a file when the file is updated.

Parameters

\Drupal\file\Entity\File $file: The file to delete the preview for.

File

src/PDFPreviewGenerator.php, line 117

Class

PDFPreviewGenerator
Generates PDF Previews.

Namespace

Drupal\pdfpreview

Code

public function updatePDFPreview(File $file) {

  /** @var \Drupal\file\Entity\File $original */
  $original = $file->original;
  if ($file
    ->getFileUri() != $original
    ->getFileUri() || filesize($file
    ->getFileUri()) != filesize($original
    ->getFileUri())) {
    $this
      ->deletePDFPreview($original);
  }
}