Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 38 additions & 33 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1589,44 +1589,49 @@
urlSpec = {};
ready(iconURL); // set mimeicon URL

urlSpec.file = OCA.Files.Files.fixPath(path);
if (options.x) {
urlSpec.x = options.x;
}
if (options.y) {
urlSpec.y = options.y;
}
if (options.a) {
urlSpec.a = options.a;
}
if (options.mode) {
urlSpec.mode = options.mode;
}
var img = new Image();

if (etag){
// use etag as cache buster
urlSpec.c = etag;
}
if (oc_appconfig.core.previewsEnabled) {
urlSpec.file = OCA.Files.Files.fixPath(path);
if (options.x) {
urlSpec.x = options.x;
}
if (options.y) {
urlSpec.y = options.y;
}
if (options.a) {
urlSpec.a = options.a;
}
if (options.mode) {
urlSpec.mode = options.mode;
}

previewURL = self.generatePreviewUrl(urlSpec);
previewURL = previewURL.replace('(', '%28');
previewURL = previewURL.replace(')', '%29');
if (etag) {
// use etag as cache buster
urlSpec.c = etag;
}

// preload image to prevent delay
// this will make the browser cache the image
var img = new Image();
img.onload = function(){
// if loading the preview image failed (no preview for the mimetype) then img.width will < 5
if (img.width > 5) {
ready(previewURL, img);
} else if (options.error) {
options.error();
previewURL = self.generatePreviewUrl(urlSpec);
previewURL = previewURL.replace('(', '%28');
previewURL = previewURL.replace(')', '%29');

// preload image to prevent delay
// this will make the browser cache the image
img.onload = function () {
// if loading the preview image failed (no preview for the mimetype) then img.width will < 5
if (img.width > 5) {
ready(previewURL, img);
} else if (options.error) {
options.error();
}
};
if (options.error) {
img.onerror = options.error;
}
};
if (options.error) {
img.onerror = options.error;
img.src = previewURL;
} else {
ready(iconURL, img);
}
img.src = previewURL;
},

/**
Expand Down
10 changes: 6 additions & 4 deletions core/js/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
)
),
"oc_appconfig" => json_encode(
array("core" => array(
[
"core" => [
'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
'defaultExpireDate' => $defaultExpireDate,
'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
Expand All @@ -163,9 +164,10 @@
'resharingAllowed' => \OCP\Share::isResharingAllowed(),
'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated'),
'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing()
)
)
'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(),
'previewsEnabled' => \OC::$server->getConfig()->getSystemValue('enable_previews', true) === true,
]
]
),
"oc_defaults" => json_encode(
array(
Expand Down