From a4900bf23fb7b3aca8e773926322742e8ccf0c3a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 1 Dec 2016 15:00:51 +0100 Subject: [PATCH] allow registering sidebar preview handlers for mimetypes that dont come with server side previews Signed-off-by: Robin Appelman --- apps/files/js/sidebarpreviewmanager.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/files/js/sidebarpreviewmanager.js b/apps/files/js/sidebarpreviewmanager.js index 3d54011918..2cf4248897 100644 --- a/apps/files/js/sidebarpreviewmanager.js +++ b/apps/files/js/sidebarpreviewmanager.js @@ -20,19 +20,28 @@ this._previewHandlers[mime] = handler; }, - getPreviewHandler: function (mime) { + getMimeTypePreviewHandler: function(mime) { var mimePart = mime.split('/').shift(); if (this._previewHandlers[mime]) { return this._previewHandlers[mime]; - } else if(this._previewHandlers[mimePart]) { + } else if (this._previewHandlers[mimePart]) { return this._previewHandlers[mimePart]; + } else { + return null; + } + }, + + getPreviewHandler: function (mime) { + var mimetypeHandler = this.getMimeTypePreviewHandler(mime); + if (mimetypeHandler) { + return mimetypeHandler; } else { return this.fallbackPreview.bind(this); } }, loadPreview: function (model, $thumbnailDiv, $thumbnailContainer) { - if (model.get('hasPreview') === false) { + if (model.get('hasPreview') === false && this.getMimeTypePreviewHandler(model.get('mimetype')) === null) { var mimeIcon = OC.MimeType.getIconUrl(model.get('mimetype')); $thumbnailDiv.removeClass('icon-loading icon-32'); $thumbnailContainer.removeClass('image'); //fall back to regular view