gpt4 book ai didi

image - ckfinder图像调整大小

转载 作者:行者123 更新时间:2023-12-04 15:37:40 27 4
gpt4 key购买 nike

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

我认为 ajax 图像调整器会解决这个问题,但无法让它工作。有人有使用自动宽度和高度调整大小插件的经验吗?

在我的 ckfinder 配置文件中,我有:

include_once "plugins/imageresize/plugin.php";

在 config.js 我有:
CKFinder.customConfig = function( config )
{
config.extraPlugins = 'imageresize';
};

最佳答案

过去,我已经为 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;
}

我怀疑你可以做一个类似的黑客,也许使用 $_SESSION 值。让您的用户选择他们需要的自动调整大小值并将其保存在他们的 $_SESSION 中。然后在您的配置文件中,查找该 session 值。就像是:
if(isset($_SESSION['resize_w']) && isset($_SESSION['resize_h']) ){
$config['Images']['maxWidth'] = $_SESSION['resize_w'];
$config['Images']['maxHeight'] = $_SESSION['resize_h'];
}

请注意,如果您还没有在 config.php 文件中调用 session_start(),则需要调用它。

关于image - ckfinder图像调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3057938/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com