Merge branch 'MDL-33378-tiff-thumb' of git://github.com/mudrd8mz/moodle
This commit is contained in:
+13
-5
@@ -2287,14 +2287,22 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
|
||||
if (!empty($options['preview'])) {
|
||||
// replace the file with its preview
|
||||
$fs = get_file_storage();
|
||||
$stored_file = $fs->get_file_preview($stored_file, $options['preview']);
|
||||
if (!$stored_file) {
|
||||
// unable to create a preview of the file
|
||||
send_header_404();
|
||||
die();
|
||||
$preview_file = $fs->get_file_preview($stored_file, $options['preview']);
|
||||
if (!$preview_file) {
|
||||
// unable to create a preview of the file, send its default mime icon instead
|
||||
if ($options['preview'] === 'tinyicon') {
|
||||
$size = 24;
|
||||
} else if ($options['preview'] === 'thumb') {
|
||||
$size = 90;
|
||||
} else {
|
||||
$size = 256;
|
||||
}
|
||||
$fileicon = file_file_icon($stored_file, $size);
|
||||
send_file($CFG->dirroot.'/pix/'.$fileicon.'.png', basename($fileicon).'.png');
|
||||
} else {
|
||||
// preview images have fixed cache lifetime and they ignore forced download
|
||||
// (they are generated by GD and therefore they are considered reasonably safe).
|
||||
$stored_file = $preview_file;
|
||||
$lifetime = DAYSECS;
|
||||
$filter = 0;
|
||||
$forcedownload = false;
|
||||
|
||||
Reference in New Issue
Block a user