code optimization

This commit is contained in:
Georg Ehrke 2013-06-11 10:56:16 +02:00
parent 0e4f5001d5
commit 2ff97917e9
6 changed files with 7 additions and 19 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}