Skip to content

Commit

Permalink
replce try-catch with if
Browse files Browse the repository at this point in the history
  • Loading branch information
wilso929 authored and wilso929 committed Nov 15, 2023
1 parent 3f0247f commit 9b13fb5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Plugin/MediaThumbnail/MediaThumbnailJp2.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function createThumbnail($sourceUri) {
$this->logger->warning($e->getMessage());
return NULL;
}
$format = ".jpg";

$im = new \Imagick();

if(file_exists("/tmp/" . $filename . ".jpg")){
Expand All @@ -55,7 +55,7 @@ public function createThumbnail($sourceUri) {
$im->clear();
$im->destroy();
// Return a new managed file object using the generated thumbnail.
return \Drupal::service('file.repository')->writeData($image, $sourceUri . $format);
return \Drupal::service('file.repository')->writeData($image, $sourceUri . ".jpg");
}

$sourceUri = \Drupal::config('media.settings')->get('icon_base_uri') . '/' . 'generic.png';
Expand All @@ -67,5 +67,4 @@ public function createThumbnail($sourceUri) {
// Return generic thumbnail.
return \Drupal::service('file.repository')->writeData($image, $sourceUri);
}

}
}

0 comments on commit 9b13fb5

Please sign in to comment.