ckfinder image resize

孤人 提交于 2019-12-01 17:36:28

In the past, I've pre-defined an auto resize value to a specific folder in ckFinder so that any image a user uploads to that folder is resized. I do that by adding a little code to the config.php file like this:

// This next block sets the default max image size and quality
$config['Images'] = Array(
        'maxWidth' => 1600,
        'maxHeight' => 1200,
        'quality' => 80);

// Here we override those settings for a given folder
if(isset($_GET['currentFolder']) && urldecode($_GET['currentFolder']) == '/some-folder-name/'){
    $config['Images']['maxWidth'] = 150;
    $config['Images']['maxHeight'] = 150;
}

I would suspect you could do a similar hack, perhaps using $_SESSION values. Have your user select the auto-resize values they need and save it in their $_SESSION. Then in your config file, look for that session value. Something like:

if(isset($_SESSION['resize_w']) && isset($_SESSION['resize_h']) ){
    $config['Images']['maxWidth'] = $_SESSION['resize_w'];
    $config['Images']['maxHeight'] = $_SESSION['resize_h'];
}

Note that you'll need to call session_start() in your config.php file if you haven't already.

Ckeditor does't resize the image,it only change the height and width value. instead of resizing the image,Set the default width and height while clicking "ok" button. Here I replace the user entered height & width values with default height & width.

 CKEDITOR.on('dialogDefinition', function (ev) {

    var dialogName = ev.data.name,
        dialogDefinition = ev.data.definition;

    if (dialogName == 'image') {
        var onOk = dialogDefinition.onOk;

        dialogDefinition.onOk = function (e) {
            var width = this.getContentElement('info', 'txtWidth');
            width.setValue('200');//Set Default Width

            var height = this.getContentElement('info', 'txtHeight');
            height.setValue('200');//Set Default height

            onOk && onOk.apply(this, e);
        };
    }
});
Prateek Deshmukh

In the "config.ascx" file change the value of variable as

Images.MaxWidth = 0; 
Images.MaxHeight = 0;
Images.Quality = 100;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!