aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-04-02 10:31:24 +0200
committerOlivier Paroz <github@oparoz.com>2015-04-02 10:31:24 +0200
commit8ec6dfdbf8e68966b1110b8e7b16019518e20bdf (patch)
treebd3eef6befa5a3fd943c758cbe2d9c647ca7c9f1
parent691c353eeda077be0fcca1e3839265815a650a90 (diff)
downloadnextcloud-server-8ec6dfdbf8e68966b1110b8e7b16019518e20bdf.tar.gz
nextcloud-server-8ec6dfdbf8e68966b1110b8e7b16019518e20bdf.zip
Split image provider in one sub-class per media type
-rw-r--r--config/config.sample.php12
-rw-r--r--lib/private/preview/bmp.php31
-rw-r--r--lib/private/preview/gif.php31
-rw-r--r--lib/private/preview/image.php10
-rw-r--r--lib/private/preview/jpeg.php31
-rw-r--r--lib/private/preview/png.php31
-rw-r--r--lib/private/preview/xbitmap.php31
-rw-r--r--lib/private/previewmanager.php30
8 files changed, 192 insertions, 15 deletions
diff --git a/config/config.sample.php b/config/config.sample.php
index 672203153c6..60932ab7d9b 100644
--- a/config/config.sample.php
+++ b/config/config.sample.php
@@ -661,7 +661,11 @@ $CONFIG = array(
*
* The following providers are enabled by default:
*
- * - OC\Preview\Image
+ * - OC\Preview\PNG
+ * - OC\Preview\JPEG
+ * - OC\Preview\GIF
+ * - OC\Preview\BMP
+ * - OC\Preview\XBitmap
* - OC\Preview\MarkDown
* - OC\Preview\MP3
* - OC\Preview\TXT
@@ -697,7 +701,11 @@ $CONFIG = array(
* - OC\Preview\StarOffice
*/
'enabledPreviewProviders' => array(
- 'OC\Preview\Image',
+ 'OC\Preview\PNG',
+ 'OC\Preview\JPEG',
+ 'OC\Preview\GIF',
+ 'OC\Preview\BMP',
+ 'OC\Preview\XBitmap',
'OC\Preview\MP3',
'OC\Preview\TXT',
'OC\Preview\MarkDown'
diff --git a/lib/private/preview/bmp.php b/lib/private/preview/bmp.php
new file mode 100644
index 00000000000..0547f053cc1
--- /dev/null
+++ b/lib/private/preview/bmp.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Preview;
+
+class BMP extends Image {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/image\/bmp/';
+ }
+}
diff --git a/lib/private/preview/gif.php b/lib/private/preview/gif.php
new file mode 100644
index 00000000000..e2b7c7e2ea2
--- /dev/null
+++ b/lib/private/preview/gif.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Preview;
+
+class GIF extends Image {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/image\/gif/';
+ }
+}
diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php
index 9770ca322e9..2c69d29f4cb 100644
--- a/lib/private/preview/image.php
+++ b/lib/private/preview/image.php
@@ -1,7 +1,7 @@
<?php
/**
* @author Georg Ehrke <georg@owncloud.com>
- * @author Georg Ehrke <georg@ownCloud.com>
+ * @author Olivier Paroz <owncloud@interfasys.ch>
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
@@ -25,13 +25,7 @@
*/
namespace OC\Preview;
-class Image extends Provider {
- /**
- * {@inheritDoc}
- */
- public function getMimeType() {
- return '/image\/(?!tiff$)(?!svg.*).*/';
- }
+abstract class Image extends Provider {
/**
* {@inheritDoc}
diff --git a/lib/private/preview/jpeg.php b/lib/private/preview/jpeg.php
new file mode 100644
index 00000000000..69edd95835c
--- /dev/null
+++ b/lib/private/preview/jpeg.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Preview;
+
+class JPEG extends Image {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/image\/jpeg/';
+ }
+}
diff --git a/lib/private/preview/png.php b/lib/private/preview/png.php
new file mode 100644
index 00000000000..f40c1dbcc88
--- /dev/null
+++ b/lib/private/preview/png.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Preview;
+
+class PNG extends Image {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/image\/png/';
+ }
+}
diff --git a/lib/private/preview/xbitmap.php b/lib/private/preview/xbitmap.php
new file mode 100644
index 00000000000..db7b85ff012
--- /dev/null
+++ b/lib/private/preview/xbitmap.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Copyright (c) 2015, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OC\Preview;
+
+class XBitmap extends Image {
+ /**
+ * {@inheritDoc}
+ */
+ public function getMimeType() {
+ return '/image\/x-xbitmap/';
+ }
+}
diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php
index c4d29261f24..78ae12cd2e5 100644
--- a/lib/private/previewmanager.php
+++ b/lib/private/previewmanager.php
@@ -188,7 +188,11 @@ class PreviewManager implements IPreview {
* List of enabled default providers
*
* The following providers are enabled by default:
- * - OC\Preview\Image
+ * - OC\Preview\PNG
+ * - OC\Preview\JPEG
+ * - OC\Preview\GIF
+ * - OC\Preview\BMP
+ * - OC\Preview\XBitmap
* - OC\Preview\MarkDown
* - OC\Preview\MP3
* - OC\Preview\TXT
@@ -215,12 +219,24 @@ class PreviewManager implements IPreview {
return $this->defaultProviders;
}
- $this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', [
- 'OC\Preview\Image',
+ $imageProviders = [
+ 'OC\Preview\PNG',
+ 'OC\Preview\JPEG',
+ 'OC\Preview\GIF',
+ 'OC\Preview\BMP',
+ 'OC\Preview\XBitmap'
+ ];
+
+ $this->defaultProviders = $this->config->getSystemValue('enabledPreviewProviders', array_merge([
'OC\Preview\MarkDown',
'OC\Preview\MP3',
'OC\Preview\TXT',
- ]);
+ ], $imageProviders));
+
+ if (in_array('OC\Preview\Image', $this->defaultProviders)) {
+ $this->defaultProviders = array_merge($this->defaultProviders, $imageProviders);
+ }
+ $this->defaultProviders = array_unique($this->defaultProviders);
return $this->defaultProviders;
}
@@ -249,7 +265,11 @@ class PreviewManager implements IPreview {
$this->registerCoreProvider('OC\Preview\TXT', '/text\/plain/');
$this->registerCoreProvider('OC\Preview\MarkDown', '/text\/(x-)?markdown/');
- $this->registerCoreProvider('OC\Preview\Image', '/image\/(?!tiff$)(?!svg.*).*/');
+ $this->registerCoreProvider('OC\Preview\PNG', '/image\/png/');
+ $this->registerCoreProvider('OC\Preview\JPEG', '/image\/jpeg/');
+ $this->registerCoreProvider('OC\Preview\GIF', '/image\/gif/');
+ $this->registerCoreProvider('OC\Preview\BMP', '/image\/bmp/');
+ $this->registerCoreProvider('OC\Preview\XBitmap', '/image\/x-xbitmap/');
$this->registerCoreProvider('OC\Preview\MP3', '/audio\/mpeg/');
// SVG, Office and Bitmap require imagick