Froala编辑器图像url路径配置 [英] Froala editor images url path configuration
本文介绍了Froala编辑器图像url路径配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用froala编辑器将图像存储在数据库中,但图像src自动更改,图像不在我的页面中查看
我尝试过:
I store image in database using froala editor but the image src is change automatic and the image not view in my page
What I have tried:
<script>
new FroalaEditor('.selector', {
// Set the image upload parameter.
imageUploadParam: 'image_param',
// Set the image upload URL.
imageUploadURL: '/upload_image',
// Additional upload params.
imageUploadParams: {id: 'my_editor'},
// Set request type.
imageUploadMethod: 'POST',
// Set max image size to 5MB.
imageMaxSize: 5 * 1024 * 1024,
// Allow to upload PNG and JPG.
imageAllowedTypes: ['jpeg', 'jpg', 'png'],
events: {
'image.beforeUpload': function (images) {
// Return false if you want to stop the image upload.
},
'image.uploaded': function (response) {
// Image was uploaded to the server.
},
'image.inserted': function ($img, response) {
// Image was inserted in the editor.
},
'image.replaced': function ($img, response) {
// Image was replaced in the editor.
},
'image.error': function (error, response) {
// Bad link.
if (error.code == 1) { ... }
// No link in upload response.
else if (error.code == 2) { ... }
// Error during image upload.
else if (error.code == 3) { ... }
// Parsing response failed.
else if (error.code == 4) { ... }
// Image too text-large.
else if (error.code == 5) { ... }
// Invalid image type.
else if (error.code == 6) { ... }
// Image can be uploaded only to same domain in IE 8 and IE 9.
else if (error.code == 7) { ... }
// Response contains the original server response to the request if available.
}
}
})
</script>
推荐答案
img ,响应){
//图像已插入编辑器中。
},
'image.replaced':function(
img, response) { // Image was inserted in the editor. }, 'image.replaced': function (
img,response){
//图像已在编辑器中替换。
},
'image.error':函数(错误,响应){
//错误的链接。
if(error.code == 1){...}
//上传响应中没有链接。
else if(error.code == 2){...}
//图片上传时出错。
else if(error.code == 3){...}
//解析响应失败。
else if(error.code == 4){...}
//图片文字太大了。
else if(error.code == 5){...}
//图像类型无效。
else if(error.code == 6){...}
//图像只能上传到IE 8和IE 9中的同一个域。
else if (error.code == 7){...}
//响应包含原始服务器对请求的响应(如果可用)。
}
}
})
< / script>
img, response) { // Image was replaced in the editor. }, 'image.error': function (error, response) { // Bad link. if (error.code == 1) { ... } // No link in upload response. else if (error.code == 2) { ... } // Error during image upload. else if (error.code == 3) { ... } // Parsing response failed. else if (error.code == 4) { ... } // Image too text-large. else if (error.code == 5) { ... } // Invalid image type. else if (error.code == 6) { ... } // Image can be uploaded only to same domain in IE 8 and IE 9. else if (error.code == 7) { ... } // Response contains the original server response to the request if available. } } }) </script>
这篇关于Froala编辑器图像url路径配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文