6

After selecting or uploading an image with the ckfinder, the user can change the width and height. I want it to automatically resize the image to the width and height the user sets. Is that possible?

I thaught that the ajax image resizer would fix that but can't get it to work. Somebody has experience with an automatic width and height resize-plugin?

In my config file of ckfinder I've got:

include_once "plugins/imageresize/plugin.php";

in the config.js I've got:

CKFinder.customConfig = function( config )
{
 config.extraPlugins = 'imageresize';
};
David Verhulst
  • 103
  • 2
  • 11

3 Answers3

3

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.

Micah Murray
  • 81
  • 1
  • 10
1

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);
        };
    }
});
Benjamin
  • 91
  • 5
0

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

Images.MaxWidth = 0; 
Images.MaxHeight = 0;
Images.Quality = 100;
Paul Roub
  • 36,322
  • 27
  • 84
  • 93