code optimization
This commit is contained in:
parent
0e4f5001d5
commit
2ff97917e9
|
@ -26,10 +26,7 @@ class Image extends Provider {
|
|||
$image->loadFromFile($fileview->getLocalFile($path));
|
||||
}
|
||||
|
||||
//check if image object is valid
|
||||
if (!$image->valid()) return false;
|
||||
|
||||
return $image;
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,14 +27,13 @@ if(!is_null(shell_exec('ffmpeg -version'))) {
|
|||
$cmd = 'ffmpeg -y -i ' . escapeshellarg($abspath) . ' -f mjpeg -vframes 1 -ss 1 ' . escapeshellarg($tmppath);
|
||||
shell_exec($cmd);
|
||||
|
||||
unlink($abspath);
|
||||
|
||||
$image = new \OC_Image($tmppath);
|
||||
if (!$image->valid()) return false;
|
||||
|
||||
unlink($abspath);
|
||||
unlink($tmppath);
|
||||
|
||||
return $image;
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,7 @@ class MP3 extends Provider {
|
|||
unlink($tmppath);
|
||||
|
||||
$image = new \OC_Image($picture);
|
||||
if (!$image->valid()) return $this->getNoCoverThumbnail($maxX, $maxY);
|
||||
|
||||
return $image;
|
||||
return $image->valid() ? $image : $this->getNoCoverThumbnail($maxX, $maxY);
|
||||
}
|
||||
|
||||
public function getNoCoverThumbnail($maxX, $maxY) {
|
||||
|
|
|
@ -32,9 +32,7 @@ if (extension_loaded('imagick')) {
|
|||
//new image object
|
||||
$image = new \OC_Image($pdf);
|
||||
//check if image object is valid
|
||||
if (!$image->valid()) return false;
|
||||
|
||||
return $image;
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ if (extension_loaded('imagick')) {
|
|||
//new image object
|
||||
$image = new \OC_Image($svg);
|
||||
//check if image object is valid
|
||||
if (!$image->valid()) return false;
|
||||
|
||||
return $image;
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,7 @@ class TXT extends Provider {
|
|||
|
||||
$image = new \OC_Image($image);
|
||||
|
||||
if (!$image->valid()) return false;
|
||||
|
||||
return $image;
|
||||
return $image->valid() ? $image : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue