Skip to content

Commit

Permalink
Add resize action on RichFIlemanager upload handler
Browse files Browse the repository at this point in the history
  • Loading branch information
almazary committed Aug 8, 2018
1 parent 533e28f commit 966be34
Show file tree
Hide file tree
Showing 12 changed files with 1,802 additions and 3 deletions.
28 changes: 25 additions & 3 deletions assets/comp/RichFilemanager/connectors/php/BaseUploadHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,11 @@ function get_config_bytes($val) {
$last = strtolower($val[strlen($val)-1]);
switch($last) {
case 'g':
$val *= 1024;
$val = (double)$val * 1024;
case 'm':
$val *= 1024;
$val = (double)$val * 1024;
case 'k':
$val *= 1024;
$val = (double)$val * 1024;
}
return $this->fix_integer_overflow($val);
}
Expand Down Expand Up @@ -1136,6 +1136,28 @@ protected function handle_file_upload($uploaded_file, $name, $size, $type, $erro
}
}
$this->set_additional_file_properties($file);

//Array ( [0] => 871 [1] => 650 [2] => 3 [3] => width="871" height="650" [bits] => 8 [mime] => image/png )
$origin_size = getimagesize($file_path);
if (!empty($origin_size[0])) {
try {
//resize and replace file path
include_once __DIR__ . '/plugins/php-image-resize/lib/ImageResize.php';

$IR = new \Gumlet\ImageResize($file_path);
$IR->resizeToWidth($origin_size[0] - 10);
$IR->resizeToHeight($origin_size[1] - 10);
$new_name = $file_path . '.temp';
$IR->save($new_name);

unlink($file_path);

rename($new_name, $file_path);
} catch (\Exception $e) {
//echo $e->__toString();die;
}
}

}
return $file;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
vendor
composer.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: php

php:
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

before_script:
- composer install

script:
- mkdir -p build/logs
- ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_success:
- travis_retry php vendor/bin/php-coveralls -v
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Turing Analytics LLP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 966be34

Please sign in to comment.