Skip to content

Commit 151a0ce

Browse files
author
Vincent Petry
authored
Merge pull request #26713 from owncloud/stable9-disable-previews
[stable9] Don't fetch preview images if `enable_previews` is set to `false`
2 parents 34bf725 + 7cf3e25 commit 151a0ce

2 files changed

Lines changed: 44 additions & 37 deletions

File tree

apps/files/js/filelist.js

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,44 +1589,49 @@
15891589
urlSpec = {};
15901590
ready(iconURL); // set mimeicon URL
15911591

1592-
urlSpec.file = OCA.Files.Files.fixPath(path);
1593-
if (options.x) {
1594-
urlSpec.x = options.x;
1595-
}
1596-
if (options.y) {
1597-
urlSpec.y = options.y;
1598-
}
1599-
if (options.a) {
1600-
urlSpec.a = options.a;
1601-
}
1602-
if (options.mode) {
1603-
urlSpec.mode = options.mode;
1604-
}
1592+
var img = new Image();
16051593

1606-
if (etag){
1607-
// use etag as cache buster
1608-
urlSpec.c = etag;
1609-
}
1594+
if (oc_appconfig.core.previewsEnabled) {
1595+
urlSpec.file = OCA.Files.Files.fixPath(path);
1596+
if (options.x) {
1597+
urlSpec.x = options.x;
1598+
}
1599+
if (options.y) {
1600+
urlSpec.y = options.y;
1601+
}
1602+
if (options.a) {
1603+
urlSpec.a = options.a;
1604+
}
1605+
if (options.mode) {
1606+
urlSpec.mode = options.mode;
1607+
}
16101608

1611-
previewURL = self.generatePreviewUrl(urlSpec);
1612-
previewURL = previewURL.replace('(', '%28');
1613-
previewURL = previewURL.replace(')', '%29');
1609+
if (etag) {
1610+
// use etag as cache buster
1611+
urlSpec.c = etag;
1612+
}
16141613

1615-
// preload image to prevent delay
1616-
// this will make the browser cache the image
1617-
var img = new Image();
1618-
img.onload = function(){
1619-
// if loading the preview image failed (no preview for the mimetype) then img.width will < 5
1620-
if (img.width > 5) {
1621-
ready(previewURL, img);
1622-
} else if (options.error) {
1623-
options.error();
1614+
previewURL = self.generatePreviewUrl(urlSpec);
1615+
previewURL = previewURL.replace('(', '%28');
1616+
previewURL = previewURL.replace(')', '%29');
1617+
1618+
// preload image to prevent delay
1619+
// this will make the browser cache the image
1620+
img.onload = function () {
1621+
// if loading the preview image failed (no preview for the mimetype) then img.width will < 5
1622+
if (img.width > 5) {
1623+
ready(previewURL, img);
1624+
} else if (options.error) {
1625+
options.error();
1626+
}
1627+
};
1628+
if (options.error) {
1629+
img.onerror = options.error;
16241630
}
1625-
};
1626-
if (options.error) {
1627-
img.onerror = options.error;
1631+
img.src = previewURL;
1632+
} else {
1633+
ready(iconURL, img);
16281634
}
1629-
img.src = previewURL;
16301635
},
16311636

16321637
/**

core/js/config.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@
154154
)
155155
),
156156
"oc_appconfig" => json_encode(
157-
array("core" => array(
157+
[
158+
"core" => [
158159
'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
159160
'defaultExpireDate' => $defaultExpireDate,
160161
'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
@@ -163,9 +164,10 @@
163164
'resharingAllowed' => \OCP\Share::isResharingAllowed(),
164165
'remoteShareAllowed' => $outgoingServer2serverShareEnabled,
165166
'federatedCloudShareDoc' => \OC::$server->getURLGenerator()->linkToDocs('user-sharing-federated'),
166-
'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing()
167-
)
168-
)
167+
'allowGroupSharing' => \OC::$server->getShareManager()->allowGroupSharing(),
168+
'previewsEnabled' => \OC::$server->getConfig()->getSystemValue('enable_previews', true) === true,
169+
]
170+
]
169171
),
170172
"oc_defaults" => json_encode(
171173
array(

0 commit comments

Comments
 (0)