Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-01-27 17:40:44 +0300
committerOlivier Paroz <github@oparoz.com>2015-01-27 17:40:44 +0300
commit25af5a16f34ff244225c2fd53e56cd68d28ed96f (patch)
tree3e3665ea5878498ef7deff6f22af3c9afc71a419 /preview
parent35e9ca02b8ed501364d46d5d1a64eb22bd1d7aa0 (diff)
Move thumbnail check to the controller
Preview should be a generic class, so moved thumbnail specific code to the controller
Diffstat (limited to 'preview')
-rw-r--r--preview/preview.php55
1 files changed, 26 insertions, 29 deletions
diff --git a/preview/preview.php b/preview/preview.php
index 91724d15..c335418b 100644
--- a/preview/preview.php
+++ b/preview/preview.php
@@ -128,9 +128,6 @@ class Preview {
$previewData = $this->getPreviewFromCore($keepAspect);
if ($previewData && $previewData->valid()) {
- if ($maxX === 200) { // Only fixing the square thumbnails
- $previewData = $this->previewValidator();
- }
$perfectPreview['preview'] = $previewData;
} else {
$perfectPreview['preview'] = $this->getMimeIcon();
@@ -150,6 +147,32 @@ class Preview {
}
/**
+ * Makes sure we return previews of the asked dimensions and fix the cache
+ * if necessary
+ *
+ * The Preview class sometimes return previews which are either wider or
+ * smaller than the asked dimensions. This happens when one of the original
+ * dimension is smaller than what is asked for
+ *
+ * @return resource
+ */
+ public function previewValidator() {
+ list($maxX, $maxY) = $this->dims;
+ $previewData = $this->preview->getPreview();
+ $previewX = $previewData->width();
+ $previewY = $previewData->height();
+
+ if (($previewX > $maxX
+ || ($previewX < $maxX || $previewY < $maxY))
+ ) {
+ $fixedPreview = $this->fixPreview($previewData, $maxX, $maxY);
+ $previewData = $this->fixPreviewCache($fixedPreview);
+ }
+
+ return $previewData;
+ }
+
+ /**
* Asks core for a preview based on our criteria
*
* @todo Need to read scaling setting from settings
@@ -179,32 +202,6 @@ class Preview {
}
/**
- * Makes sure we return previews of the asked dimensions and fix the cache
- * if necessary
- *
- * The Preview class sometimes return previews which are either wider or
- * smaller than the asked dimensions. This happens when one of the original
- * dimension is smaller than what is asked for
- *
- * @return resource
- */
- private function previewValidator() {
- list($maxX, $maxY) = $this->dims;
- $previewData = $this->preview->getPreview();
- $previewX = $previewData->width();
- $previewY = $previewData->height();
-
- if (($previewX > $maxX
- || ($previewX < $maxX || $previewY < $maxY))
- ) {
- $fixedPreview = $this->fixPreview($previewData, $maxX, $maxY);
- $previewData = $this->fixPreviewCache($fixedPreview);
- }
-
- return $previewData;
- }
-
- /**
* Makes a preview fit in the asked dimension and fills the empty space
*
* @param \OC_Image $previewData