diff options
Diffstat (limited to 'lib/private/preview.php')
-rwxr-xr-x | lib/private/preview.php | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/private/preview.php b/lib/private/preview.php index 6172519c7d1..aeb9806904a 100755 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -13,6 +13,7 @@ */ namespace OC; +use OC\Files\Filesystem; use OC\Preview\Provider; require_once 'preview/image.php'; @@ -732,6 +733,35 @@ class Preview { } /** + * Check if a preview can be generated for a file + * + * @param \OC\Files\FileInfo $file + * @return bool + */ + public static function isAvailable($file) { + if (!\OC_Config::getValue('enable_previews', true)) { + return false; + } + + //check if there are preview backends + if (empty(self::$providers)) { + self::initProviders(); + } + + //remove last element because it has the mimetype * + $providers = array_slice(self::$providers, 0, -1); + foreach ($providers as $supportedMimeType => $provider) { + /** + * @var \OC\Preview\Provider $provider + */ + if (preg_match($supportedMimeType, $file->getMimetype())) { + return $provider->isAvailable($file); + } + } + return false; + } + + /** * @param string $mimeType * @return bool */ |