Commit 2ff97917 authored by Georg Ehrke's avatar Georg Ehrke
Browse files

code optimization

parent 0e4f5001
......@@ -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;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment