From d720a2fb5719122a0250d63c269380c6ba413755 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 16 Oct 2016 20:42:35 +0200 Subject: Moved over files_versions Signed-off-by: Roeland Jago Douma --- lib/private/Preview/Generator.php | 15 ++++++++++----- lib/private/PreviewManager.php | 5 +++-- lib/public/IPreview.php | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/private/Preview/Generator.php b/lib/private/Preview/Generator.php index ea162926afa..d4c38b1cb6a 100644 --- a/lib/private/Preview/Generator.php +++ b/lib/private/Preview/Generator.php @@ -76,11 +76,15 @@ class Generator { * @param int $height * @param bool $crop * @param string $mode + * @param string $mimeType * @return ISimpleFile * @throws NotFoundException */ - public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL) { - if (!$this->previewManager->isMimeSupported($file->getMimeType())) { + public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null) { + if ($mimeType === null) { + $mimeType = $file->getMimeType(); + } + if (!$this->previewManager->isMimeSupported($mimeType)) { throw new NotFoundException(); } @@ -91,7 +95,7 @@ class Generator { $previewFolder = $this->getPreviewFolder($file); // Get the max preview and infer the max preview sizes from that - $maxPreview = $this->getMaxPreview($previewFolder, $file); + $maxPreview = $this->getMaxPreview($previewFolder, $file, $mimeType); list($maxWidth, $maxHeight) = $this->getPreviewSize($maxPreview); // Calculate the preview size @@ -110,10 +114,11 @@ class Generator { /** * @param ISimpleFolder $previewFolder * @param File $file + * @param string $mimeType * @return ISimpleFile * @throws NotFoundException */ - private function getMaxPreview(ISimpleFolder $previewFolder, File $file) { + private function getMaxPreview(ISimpleFolder $previewFolder, File $file, $mimeType) { $nodes = $previewFolder->getDirectoryListing(); foreach ($nodes as $node) { @@ -124,7 +129,7 @@ class Generator { $previewProviders = $this->previewManager->getProviders(); foreach ($previewProviders as $supportedMimeType => $providers) { - if (!preg_match($supportedMimeType, $file->getMimeType())) { + if (!preg_match($supportedMimeType, $mimeType)) { continue; } diff --git a/lib/private/PreviewManager.php b/lib/private/PreviewManager.php index 0cda55751bf..2c17a5f3c80 100644 --- a/lib/private/PreviewManager.php +++ b/lib/private/PreviewManager.php @@ -151,11 +151,12 @@ class PreviewManager implements IPreview { * @param int $height * @param bool $crop * @param string $mode + * @param string $mimeType * @return ISimpleFile * @throws NotFoundException * @since 9.2.0 */ - public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL) { + public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null) { if ($this->generator === null) { $this->generator = new Generator( $this->rootFolder, @@ -165,7 +166,7 @@ class PreviewManager implements IPreview { ); } - return $this->generator->getPreview($file, $width, $height, $crop, $mode); + return $this->generator->getPreview($file, $width, $height, $crop, $mode, $mimeType); } /** diff --git a/lib/public/IPreview.php b/lib/public/IPreview.php index 0942db4784c..c6417b4d182 100644 --- a/lib/public/IPreview.php +++ b/lib/public/IPreview.php @@ -96,11 +96,12 @@ interface IPreview { * @param int $height * @param bool $crop * @param string $mode + * @param string $mimeType To force a given mimetype for the file (files_versions needs this) * @return ISimpleFile * @throws NotFoundException * @since 9.2.0 */ - public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL); + public function getPreview(File $file, $width = -1, $height = -1, $crop = false, $mode = IPreview::MODE_FILL, $mimeType = null); /** * Returns true if the passed mime type is supported -- cgit v1.2.3