summaryrefslogtreecommitdiffstats
path: root/apps/files/lib
diff options
context:
space:
mode:
authorNina Pypchenko <22447785+nina-py@users.noreply.github.com>2021-01-10 19:14:49 +1100
committernpmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>2021-01-14 17:36:17 +0000
commitc14638877c0bb0533a72842ccc7c73d88f5122f0 (patch)
treebac7b25321ce61e30b578f51a9692ff52955edc8 /apps/files/lib
parent97743df3fcd6243f9b2755a4c86586b61a96e793 (diff)
downloadnextcloud-server-c14638877c0bb0533a72842ccc7c73d88f5122f0.tar.gz
nextcloud-server-c14638877c0bb0533a72842ccc7c73d88f5122f0.zip
Add "Crop image previews" setting to files
Added a new user setting that toggles cropping on image previews in grid view. True (default value): crops each image to a square. False: keep original aspect ratio. Signed-off-by: Nina Pypchenko <22447785+nina-py@users.noreply.github.com> Closes #18439. Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
Diffstat (limited to 'apps/files/lib')
-rw-r--r--apps/files/lib/Controller/ApiController.php14
-rw-r--r--apps/files/lib/Controller/ViewController.php2
2 files changed, 16 insertions, 0 deletions
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php
index a852be5dad5..2b8d62efb7c 100644
--- a/apps/files/lib/Controller/ApiController.php
+++ b/apps/files/lib/Controller/ApiController.php
@@ -281,6 +281,20 @@ class ApiController extends Controller {
}
/**
+ * Toggle default for cropping preview images
+ *
+ * @NoAdminRequired
+ *
+ * @param bool $crop
+ * @return Response
+ * @throws \OCP\PreConditionNotMetException
+ */
+ public function cropImagePreviews($crop) {
+ $this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', 'crop_image_previews', (int)$crop);
+ return new Response();
+ }
+
+ /**
* Toggle default for files grid view
*
* @NoAdminRequired
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 91075737525..364735437e4 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -296,6 +296,8 @@ class ViewController extends Controller {
$params['isIE'] = \OCP\Util::isIE();
$showHidden = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_hidden', false);
$params['showHiddenFiles'] = $showHidden ? 1 : 0;
+ $cropImagePreviews = (bool) $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'crop_image_previews', true);
+ $params['cropImagePreviews'] = $cropImagePreviews ? 1 : 0;
$params['fileNotFound'] = $fileNotFound ? 1 : 0;
$params['appNavigation'] = $nav;
$params['appContents'] = $contentItems;