ckfinder图像调整大小

Dav*_*lst 6 resize image ckfinder

使用ckfinder选择或上传图像后,用户可以更改宽度和高度.我希望它自动将图像调整为用户设置的宽度和高度.那可能吗?

我认为ajax图像缩放器会解决这个问题但无法使其工作.有人有自动宽度和高度调整插件的经验吗?

在我的ckfinder配置文件中,我得到了:

include_once "plugins/imageresize/plugin.php";
Run Code Online (Sandbox Code Playgroud)

在config.js我有:

CKFinder.customConfig = function( config )
{
 config.extraPlugins = 'imageresize';
};
Run Code Online (Sandbox Code Playgroud)

Mic*_*ray 3

过去,我在 ckFinder 中为特定文件夹预定义了一个自动调整大小值,以便调整用户上传到该文件夹​​的任何图像的大小。我通过向 config.php 文件添加一些代码来实现这一点,如下所示:

// 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;
}
Run Code Online (Sandbox Code Playgroud)

我怀疑你可以做类似的黑客,也许使用 $_SESSION 值。让您的用户选择他们需要的自动调整大小值并将其保存在他们的 $_SESSION 中。然后在您的配置文件中查找该会话值。就像是:

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

请注意,如果尚未调用,则需要在 config.php 文件中调用 session_start()。