diff --git a/lib/Listener/LoadViewerScript.php b/lib/Listener/LoadViewerScript.php index 552a22b78..a68dc8b5a 100644 --- a/lib/Listener/LoadViewerScript.php +++ b/lib/Listener/LoadViewerScript.php @@ -14,6 +14,7 @@ use OCP\AppFramework\Services\IInitialState; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; +use OCP\IConfig; use OCP\IPreview; use OCP\Util; @@ -22,13 +23,16 @@ * @psalm-api */ class LoadViewerScript implements IEventListener { + private IConfig $config; private IInitialState $initialStateService; private IPreview $previewManager; public function __construct( + IConfig $config, IInitialState $initialStateService, IPreview $previewManager, ) { + $this->config = $config; $this->initialStateService = $initialStateService; $this->previewManager = $previewManager; } @@ -43,5 +47,10 @@ public function handle(Event $event): void { Util::addInitScript(Application::APP_ID, 'viewer-init'); Util::addScript(Application::APP_ID, 'viewer-main', 'files'); $this->initialStateService->provideInitialState('enabled_preview_providers', array_keys($this->previewManager->getProviders())); + $this->initialStateService->provideInitialState('disable_preview',$this->getSystemValue('disable_preview_in_viewer')); } + + public function getSystemValue(string $key) { + return $this->config->getSystemValue($key, false); + } } diff --git a/src/components/Images.vue b/src/components/Images.vue index dd07e1441..9f52a204d 100644 --- a/src/components/Images.vue +++ b/src/components/Images.vue @@ -88,6 +88,8 @@ import { findLivePhotoPeerFromFileId } from '../utils/livePhotoUtils' import { getDavPath } from '../utils/fileUtils' import { preloadMedia } from '../services/mediaPreloader' +import { loadState } from '@nextcloud/initial-state' + Vue.use(AsyncComputed) export default { @@ -117,6 +119,7 @@ export default { pinchDistance: 0, pinchStartZoomRatio: 1, pointerCache: [], + disablePreview: loadState(appName, 'disable_preview', false) } }, @@ -180,6 +183,11 @@ export default { return this.src } + // If disablePreview is set in config.php then return the original file source + if(this.disablePreview) { + return this.src; + } + // If there is no preview and we have a direct source // load it instead if (this.source && !this.hasPreview && !this.previewUrl) {