Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Fix video file handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarpsvo committed Mar 11, 2022
1 parent e62f3e4 commit 332f0ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Classes/MediaHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected function normalizeFileName($filename): string
}

/**
* @param $tempFilePath
* @param string $tempFilePath
* @param $path - Path on disk
* @param $mimeType
* @param $disk - Saving destination
Expand All @@ -139,6 +139,7 @@ public function generateImageSizes($tempFilePath, $path, $mimeType, $disk): arra
'ffprobe.binaries' => env('FFPROBE_PATH'),
])->open($tempFilePath);
$video->frame(TimeCode::fromSeconds(1))->save($thumbnailTmpFile);

$img = Image::make($thumbnailTmpFile);
$origExtension = 'jpg';
} else {
Expand Down Expand Up @@ -346,7 +347,7 @@ protected function storeFile($fileData, $disk): Media
$watermark = Image::make($watermarkPath);

$posConf = config('nova-media-field.watermark_positon', ['position' => 'center', 'x' => 0, 'y' => 0]);

$newFile = $disk->get($storagePath . $newFilename);
$watermarkImg = Image::make($newFile)
->insert($watermark, $posConf['position'], $posConf['x'], $posConf['y'])
Expand Down Expand Up @@ -389,7 +390,9 @@ protected function storeFile($fileData, $disk): Media


if (($isImageFile || $isVideoFile) && $withThumbnails) {
$generatedImages = $this->generateImageSizes($image, $fullFilePath, $mimeType, $disk);
// We will have $image if it was an image file
// For video files, pass temp file path
$generatedImages = $this->generateImageSizes($image ?? ($tmpPath . $tmpName), $fullFilePath, $mimeType, $disk);

if (!empty($watermarkPath)) $generatedImages['watermark']['file_name'] = $watermarkFileName;

Expand Down

0 comments on commit 332f0ba

Please sign in to comment.