From c14638877c0bb0533a72842ccc7c73d88f5122f0 Mon Sep 17 00:00:00 2001 From: Nina Pypchenko <22447785+nina-py@users.noreply.github.com> Date: Sun, 10 Jan 2021 19:14:49 +1100 Subject: 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] --- apps/files/js/filelist.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'apps/files/js/filelist.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 30bc35551d6..11d0bc4511d 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -252,7 +252,8 @@ this._filesConfig = OCA.Files.App.getFilesConfig(); } else { this._filesConfig = new OC.Backbone.Model({ - 'showhidden': false + 'showhidden': false, + 'cropimagepreviews': true }); } @@ -291,6 +292,10 @@ } }); + this._filesConfig.on('change:cropimagepreviews', function() { + self.reload(); + }); + this.$el.toggleClass('hide-hidden-files', !this._filesConfig.get('showhidden')); } @@ -2215,6 +2220,12 @@ urlSpec.y = Math.ceil(urlSpec.y); urlSpec.forceIcon = 0; + /** + * Images are cropped to a square by default. Append a=1 to the URL + * if the user wants to see images with original aspect ratio. + */ + urlSpec.a = this._filesConfig.get('cropimagepreviews') ? 0 : 1; + if (typeof urlSpec.fileId !== 'undefined') { delete urlSpec.file; return OC.generateUrl('/core/preview?') + $.param(urlSpec); -- cgit v1.2.3