Fixed error 500 on trying to generate thumbnails for audio without an embedded cover image.
This commit is contained in:
parent
ecf11693b0
commit
c73718b1fd
1 changed files with 21 additions and 5 deletions
|
@ -108,11 +108,27 @@ class UploadsContext {
|
|||
$imagick = new Imagick;
|
||||
|
||||
if($uploadInfo->isImage()) {
|
||||
$imagick->readImageBlob(file_get_contents($filePath));
|
||||
} elseif($uploadInfo->isAudio())
|
||||
$imagick->readImageBlob(FFMPEG::grabAudioCover($filePath));
|
||||
elseif($uploadInfo->isVideo())
|
||||
$imagick->readImageBlob(FFMPEG::grabVideoFrame($filePath));
|
||||
try {
|
||||
$file = fopen($filePath, 'rb');
|
||||
$imagick->readImageFile($file);
|
||||
} finally {
|
||||
if(isset($file) && is_resource($file))
|
||||
fclose($file);
|
||||
}
|
||||
} elseif($uploadInfo->isAudio()) {
|
||||
// Index\IO\Stream needs some way to grab the underlying handle so we can use readImageFile
|
||||
$stream = (string)FFMPEG::grabAudioCover($filePath);
|
||||
if($stream === '')
|
||||
return '';
|
||||
|
||||
$imagick->readImageBlob($stream);
|
||||
} elseif($uploadInfo->isVideo()) {
|
||||
$stream = (string)FFMPEG::grabVideoFrame($filePath);
|
||||
if($stream === '')
|
||||
return '';
|
||||
|
||||
$imagick->readImageBlob($stream);
|
||||
}
|
||||
|
||||
$imagick->setImageFormat('jpg');
|
||||
$imagick->setImageCompressionQuality($this->config->getInteger('thumb:quality', 40));
|
||||
|
|
Loading…
Reference in a new issue