diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-07-31 11:38:29 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-07-31 11:38:29 +0200 |
commit | 4eb2b4e1b087234499f2721bc474fa979a47f1e0 (patch) | |
tree | ef5be6c1204bdc0fe11cf1009684496f4ab426f4 /lib/private/preview.php | |
parent | c1562057e813ff1dcb0e28b9616c528975fc3b5d (diff) | |
parent | 4a9b0d5465927b0b4cc856cebbc724264ffdd404 (diff) | |
download | nextcloud-server-4eb2b4e1b087234499f2721bc474fa979a47f1e0.tar.gz nextcloud-server-4eb2b4e1b087234499f2721bc474fa979a47f1e0.zip |
Merge pull request #10051 from owncloud/preview-empty-text
Use svg mimeicons for empty text files
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 */ |