ckfinder图像调整大小 [英] ckfinder image resize
问题描述
使用ckfinder选择或上传图像后,用户可以更改宽度和高度。我希望它能自动将图像调整为用户设置的宽度和高度。这可能吗?
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?
我认为ajax图像缩放器会修复它但无法使其工作。有人有自动宽度和高度调整插件的经验吗?
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?
在我的ckfinder配置文件中我得到了:
In my config file of ckfinder I've got:
include_once "plugins/imageresize/plugin.php";
在config.js我有:
in the config.js I've got:
CKFinder.customConfig = function( config )
{
config.extraPlugins = 'imageresize';
};
推荐答案
过去,我已经预定了一个自动调整ckFinder中特定文件夹的值,以便调整用户上传到该文件夹的任何图像的大小。我这样做是通过在config.php文件中添加一些代码,如下所示:
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;
}
我怀疑你可以做类似的黑客攻击,也许使用$ _SESSION值。让您的用户选择他们需要的自动调整大小值并将其保存在$ _SESSION中。然后在配置文件中查找该会话值。类似于:
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'];
}
请注意,您需要在config.php中调用session_start()文件,如果你还没有。
Note that you'll need to call session_start() in your config.php file if you haven't already.
这篇关于ckfinder图像调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!