ckeditor property to resize a image

青春壹個敷衍的年華 提交于 2020-01-24 00:34:06

问题


Is there any property in ckeditor that will resize the image after uploading to a specified dimension. for eg: if user uploads a image of 1000*1000 px and doesn't resize it, it can be a massacre. As i am saving and displaying on the same page without refresh using ajax. All i want is to automatically resize image on upload from ckeditor. As well, is there any way that i can find using jquery whether there is any image in the text saved by user, as a user may or may not upload a image, I am using inplace ckeditor.


回答1:


CKFinder is an excellent companion to CKEditor, and allows one to set the maximum size of an uploaded image in its configuration.

If you don't want to use that, you resize the image yourself in PHP with something like this:

<?php
$maxWidth  = 250;
$maxHeight = 500;

$size = getimagesize($url);
if ($size) {
    $imageWidth  = $size[0];
    $imageHeight = $size[1];
    $wRatio = $imageWidth / $maxWidth;
    $hRatio = $imageHeight / $maxHeight;
    $maxRatio = max($wRatio, $hRatio);
    if ($maxRatio > 1) {
        $outputWidth = $imageWidth / $maxRatio;
        $outputHeight = $imageHeight / $maxRatio;
    } else {
        $outputWidth = $imageWidth;
        $outputHeight = $imageHeight;
    }
}
?>

From: Arbitrary image resizing in PHP



来源:https://stackoverflow.com/questions/6339664/ckeditor-property-to-resize-a-image

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