File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 66 */
77
88use Chamilo \CoreBundle \Component \Editor \Driver \Driver ;
9+ use Chamilo \CoreBundle \Component \Editor \Driver \PersonalDriver ;
910
1011require_once __DIR__ .'/../global.inc.php ' ;
1112
225226 exit ;
226227 }
227228
229+ $ resizeMax = api_get_configuration_value ('wysiwyg_image_auto_resize_max ' );
230+
231+ if (is_array ($ resizeMax )) {
232+ if ($ fileUpload ['size ' ] > ($ resizeMax ['mb ' ] * 1024 * 1024 )) {
233+ echo json_encode ([
234+ 'uploaded ' => 0 ,
235+ 'error ' => [
236+ 'message ' => get_lang ('UplFileTooBig ' ),
237+ ]
238+ ]);
239+
240+ exit ;
241+ }
242+
243+ $ temp = new Image ($ fileUpload ['tmp_name ' ]);
244+ $ pictureInfo = $ temp ->get_image_info ();
245+
246+ $ thumbSize = 0 ;
247+
248+ if ($ pictureInfo ['width ' ] > $ pictureInfo ['height ' ]) {
249+ if ($ pictureInfo ['width ' ] > $ resizeMax ['w ' ]) {
250+ $ thumbSize = $ resizeMax ['w ' ];
251+ }
252+ } else {
253+ if ($ pictureInfo ['height ' ] > $ resizeMax ['h ' ]) {
254+ $ thumbSize = $ resizeMax ['h ' ];
255+ }
256+ }
257+
258+ if ($ thumbSize ) {
259+ $ temp ->resize ($ thumbSize );
260+ $ temp ->send_image ($ fileUpload ['tmp_name ' ]);
261+ $ fileUpload ['size ' ] = filesize ($ fileUpload ['tmp_name ' ]);
262+ }
263+ }
264+
228265 $ isAllowedToEdit = api_is_allowed_to_edit (null , true );
229266 if ($ isAllowedToEdit ) {
230267 $ globalFile = ['files ' => $ fileUpload ];
Original file line number Diff line number Diff line change 22962296// Enable image upload as file when doing a copy in the content or a drag and drop.
22972297//$_configuration['enable_uploadimage_editor'] = false;
22982298
2299+ // Automatic image resize before upload image with CKEditor
2300+ /*$_configuration['wysiwyg_image_auto_resize_max'] = [
2301+ 'w'=> 800, //max width
2302+ 'h' => 600, //max height
2303+ 'mb' => 2 //max size (in MB)
2304+ ];*/
2305+
22992306// Ckeditor settings.
23002307//$_configuration['editor_settings'] = ['config' => ['youtube_responsive' => true, 'image_responsive' => true]];
23012308
You can’t perform that action at this time.
0 commit comments