From 1be43bdeeb30b61902ea3bcfee4535026ed3c822 Mon Sep 17 00:00:00 2001
From: Rhys Tyers <5313660+rhyst@users.noreply.github.com>
Date: Wed, 31 May 2023 12:35:40 +0100
Subject: [PATCH] Add configuration for full res on zoom and full res always
for public shares
---
lib/Controller/OtherController.php | 3 +++
lib/SystemConfigDefault.php | 3 +++
src/components/admin/AdminTypes.ts | 3 +++
src/components/admin/sections/FileSupport.vue | 21 +++++++++++++++++++
src/components/viewer/Viewer.vue | 5 ++++-
src/services/static-config.ts | 16 ++++++++------
src/types.ts | 2 ++
7 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php
index c807b830..20715a03 100644
--- a/lib/Controller/OtherController.php
+++ b/lib/Controller/OtherController.php
@@ -94,6 +94,9 @@ class OtherController extends GenericApiController
'sort_folder_month' => 'true' === $getAppConfig('sortFolderMonth', false),
'sort_album_month' => 'true' === $getAppConfig('sortAlbumMonth', 'true'),
'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'),
+
+ 'public_full_res_on_zoom' => Util::getSystemConfig('memories.public_full_res_on_zoom'),
+ 'public_full_res_always' => Util::getSystemConfig('memories.public_full_res_always'),
], Http::STATUS_OK);
});
}
diff --git a/lib/SystemConfigDefault.php b/lib/SystemConfigDefault.php
index b1709bf5..65717ff5 100644
--- a/lib/SystemConfigDefault.php
+++ b/lib/SystemConfigDefault.php
@@ -69,4 +69,7 @@ return [
'preview_max_y' => 4096,
'preview_max_memory' => 128,
'preview_max_filesize_image' => 50,
+
+ 'memories.public_full_res_on_zoom' => true,
+ 'memories.public_full_res_always' => false,
];
diff --git a/src/components/admin/AdminTypes.ts b/src/components/admin/AdminTypes.ts
index 12c73042..8b1dc87d 100644
--- a/src/components/admin/AdminTypes.ts
+++ b/src/components/admin/AdminTypes.ts
@@ -28,6 +28,9 @@ export type ISystemConfig = {
preview_max_y: number;
preview_max_memory: number;
preview_max_filesize_image: number;
+
+ 'memories.public_full_res_on_zoom': boolean;
+ 'memories.public_full_res_always': boolean;
};
export type IBinaryStatus = 'ok' | 'not_found' | 'not_executable' | 'test_ok' | string;
diff --git a/src/components/admin/sections/FileSupport.vue b/src/components/admin/sections/FileSupport.vue
index e5e48dfb..97bf81fc 100644
--- a/src/components/admin/sections/FileSupport.vue
+++ b/src/components/admin/sections/FileSupport.vue
@@ -62,6 +62,27 @@
:value="String(config['preview_max_filesize_image'])"
@change="update('preview_max_filesize_image', Number($event.target.value))"
/>
+
+
+ {{ t('memories', 'You can set the image viewer to always request a full size image when an image is opened for public folders (there is seperate user setting for logged in users).') }}
+ {{ t('memories', 'This is not recommended if the images require transcoding (i.e. heic images) because it will cause a large amount of CPU usage.') }}
+
+
+
+ {{ t('memories', 'Load full size image on zoom for public folders') }}
+
+
+
+ {{ t('memories', 'Always load full size image for public folders') }}
+
diff --git a/src/components/viewer/Viewer.vue b/src/components/viewer/Viewer.vue
index dd48a7dd..16467a3c 100644
--- a/src/components/viewer/Viewer.vue
+++ b/src/components/viewer/Viewer.vue
@@ -797,7 +797,10 @@ export default defineComponent({
: photo.flag & this.c.FLAG_IS_LOCAL
? nativex.API.IMAGE_FULL(photo.fileid)
: API.IMAGE_DECODABLE(photo.fileid, photo.etag);
- const fullLoadCond = this.config.full_res_always ? 'always' : this.config.full_res_on_zoom ? 'zoom' : 'never';
+
+ const fullResOnZoom = this.routeIsPublic ? this.config.public_full_res_on_zoom : this.config.full_res_on_zoom;
+ const fullResAlways = this.routeIsPublic ? this.config.public_full_res_always : this.config.full_res_always;
+ const fullLoadCond = fullResAlways ? 'always' : fullResOnZoom ? 'zoom' : 'never';
return {
src: previewUrl,
diff --git a/src/services/static-config.ts b/src/services/static-config.ts
index ecefdfd8..e55bbf4f 100644
--- a/src/services/static-config.ts
+++ b/src/services/static-config.ts
@@ -1,12 +1,13 @@
-import axios from '@nextcloud/axios';
-import { showInfo, showError } from '@nextcloud/dialogs';
-import { API } from './API';
-import { IConfig } from '../types';
-import { getBuilder } from '@nextcloud/browser-storage';
-import { translate as t } from '@nextcloud/l10n';
import * as utils from './Utils';
+import { showError, showInfo } from '@nextcloud/dialogs';
+
+import { API } from './API';
+import { IConfig } from '../types';
import type Storage from '@nextcloud/browser-storage/dist/storage';
+import axios from '@nextcloud/axios';
+import { getBuilder } from '@nextcloud/browser-storage';
+import { translate as t } from '@nextcloud/l10n';
class StaticConfig {
private config: IConfig | null = null;
@@ -120,6 +121,9 @@ class StaticConfig {
full_res_always: false,
show_face_rect: false,
album_list_sort: 1,
+
+ public_full_res_on_zoom: true,
+ public_full_res_always: false,
};
for (const key in config) {
diff --git a/src/types.ts b/src/types.ts
index 12a81720..9399dd6c 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -254,6 +254,8 @@ export type IConfig = {
square_thumbs: boolean;
full_res_on_zoom: boolean;
full_res_always: boolean;
+ public_full_res_on_zoom: boolean;
+ public_full_res_always: boolean;
show_face_rect: boolean;
album_list_sort: 1 | 2;
};