Improve thumbnail creation
This commit is contained in:
parent
28370a9902
commit
c16fed9b50
|
@ -25,14 +25,25 @@ class File extends MY_Controller
|
||||||
header("Content-Disposition: attachment; filename=" . $file['name'] . '.' . explode('/', $file['type'])[1]);
|
header("Content-Disposition: attachment; filename=" . $file['name'] . '.' . explode('/', $file['type'])[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$imagePath = 'files' . DIRECTORY_SEPARATOR .
|
$isThumb = isset($_GET['w']) || isset($_GET['h']);
|
||||||
($file['isUserData'] ? 'userContent' . DIRECTORY_SEPARATOR : '') .
|
$w = isset($_GET['w']) ? $_GET['w'] : false;
|
||||||
(isset($_GET['w']) || isset($_GET['h']) ? 'thumbs' . DIRECTORY_SEPARATOR : '') .
|
$h = isset($_GET['h']) ? $_GET['h'] : false;
|
||||||
$file['name'] . (isset($_GET['w']) ? '_w' . $_GET['w'] : '') .
|
$imagePath = pathinfo($file['path'], PATHINFO_DIRNAME) . '/' .
|
||||||
(isset($_GET['h']) ? '_h' . $_GET['h'] : '') . '.' .
|
($isThumb ? 'thumbs/' : '') .
|
||||||
explode('.', $file['path'])[1];
|
$file['name'] .
|
||||||
|
($w ? '_w' . $w : '') .
|
||||||
|
($h ? '_h' . $h : '') .
|
||||||
|
'.' . pathinfo($file['path'], PATHINFO_EXTENSION);
|
||||||
|
|
||||||
if (!file_exists($imagePath)) {
|
if (!file_exists($imagePath)) {
|
||||||
|
if(!$isThumb)
|
||||||
|
exit;
|
||||||
|
|
||||||
|
$dir = pathinfo($imagePath, PATHINFO_DIRNAME);
|
||||||
|
if(!file_exists($dir)) {
|
||||||
|
mkdir(pathinfo($dir, 0777));
|
||||||
|
}
|
||||||
|
|
||||||
$config['image_library'] = 'gd2';
|
$config['image_library'] = 'gd2';
|
||||||
$config['source_image'] = $file['path'];
|
$config['source_image'] = $file['path'];
|
||||||
if (isset($_GET['w'])) {
|
if (isset($_GET['w'])) {
|
||||||
|
|
Reference in New Issue
Block a user