问题描述
ckeditor中有任何属性会在上传到指定维度后调整图片大小。例如:如果用户上传 1000 * 1000 px
的图像,并且不调整其大小,则可以是大屠杀。因为我保存和显示在同一页上,而不使用ajax刷新。
所有我想要的是从ckeditor上传时自动调整图像大小。
此外,是否有任何方式,我可以找到使用jquery是否有任何图像在用户保存的文本,因为用户可能或不可以上传图像,我使用inplace ckeditor。
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.
推荐答案
是一个优秀的伴侣到CKEditor,并允许在。
CKFinder is an excellent companion to CKEditor, and allows one to set the maximum size of an uploaded image in its configuration.
如果您不想使用它,您可以在PHP中自行调整图片大小,例如:
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:
这篇关于ckeditor属性来调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!