diff options
| author | Benjamin Southall <applemansigloo@gmail.com> | 2017-03-05 01:41:52 +0900 |
|---|---|---|
| committer | Benjamin Southall <applemansigloo@gmail.com> | 2017-03-05 01:41:52 +0900 |
| commit | f3a5eb094079b8a2184e62ac6c727c36da658abd (patch) | |
| tree | 88d928db29e1d9d788837c62e048b00956bc9ce5 | |
| parent | 56844619023b0030ef87ede4b5c06a9b94329f27 (diff) | |
Initial implementation for Thumbnails for PDFs / other things #6, requires ['pdf_file_thumbnail'] is set to true and using convert from imagemagick. If ['pdf_file_thumbnail'] is false then it uses standard configured static file icon
| -rw-r--r-- | post.php | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -985,6 +985,25 @@ if (isset($_POST['delete'])) { } $image->destroy(); } else { + if ($file['extension'] == "pdf" && $config['pdf_file_thumbnail']){ + $path = $file['thumb']; + $error = shell_exec_error( 'convert -thumbnail x300 -background white -alpha remove ' . + escapeshellarg($file['tmp_name']. '[0]') . ' ' . + escapeshellarg($file['thumb'])); + + if ($error){ + $path = sprintf($config['file_thumb'],isset($config['file_icons'][$file['extension']]) ? $config['file_icons'][$file['ext + ension']] : $config['file_icons']['default']); + } + + $file['thumb'] = basename($file['thumb']); + $size = @getimagesize($path); + $file['thumbwidth'] = $size[0]; + $file['thumbheight'] = $size[1]; + $file['width'] = $size[0]; + $file['height'] = $size[1]; + } + else { // not an image //copy($config['file_thumb'], $post['thumb']); $file['thumb'] = 'file'; @@ -994,6 +1013,7 @@ if (isset($_POST['delete'])) { $config['file_icons'][$file['extension']] : $config['file_icons']['default'])); $file['thumbwidth'] = $size[0]; $file['thumbheight'] = $size[1]; + } } if ($config['tesseract_ocr'] && $file['thumb'] != 'file') { // Let's OCR it! |
