可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
When trying to use ckeditor for the first time. ckeditor works, but when I try to add imageupload and uploadloadwidget plugins then I get the error: Uncaught TypeError: Cannot read property 'icons' of null
Does anyone have any ideas as to what might be causing it?
<script src="//cdn.ckeditor.com/4.5.6/basic/ckeditor.js"></script> <script> $(document).ready(function () { CKEDITOR.plugins.addExternal('imageupload', '/ckeditor/plugins/imageupload/'); CKEDITOR.plugins.addExternal('uploadwidget', '/ckeditor/plugins/uploadwidget/'); CKEDITOR.replace('htmleditor', { htmlEncodeOutput: true, extraPlugins: 'imageupload,uploadwidget' }); }); </script>
回答1:
Kindly take a look at this http://ckeditor.com/addon/uploadimage and this http://sdk.ckeditor.com/samples/fileupload.html#uploading-dropped-and-pasted-images for reference.
You'll have to setup the upload url and enable the uploadimage plugin in the configs like this:
config.extraPlugins = 'uploadimage'; config.imageUploadUrl = '/uploader/upload.php?type=Images'; editor.on( 'fileUploadRequest', function( evt ) { var fileLoader = evt.data.fileLoader, formData = new FormData(), xhr = fileLoader.xhr; xhr.open( 'PUT', fileLoader.uploadUrl, true ); formData.append( 'upload', fileLoader.file, fileLoader.fileName ); fileLoader.xhr.send( formData ); // Prevented the default behavior. evt.stop(); }, null, null, 4 ); // Listener with a priority 4 will be executed before priority 5.
The docs has more info on this and how to handle different scenarios
回答2:
Make sure your path has pointed to a valid icon file, is it .ico? or .png? if not set your path to the valid image/icon file. This should solve the problem.
回答3:
Too late for the original poster, but I had this same problem and it turned out that I hadn't included the UploadWidget pluging that UploadImage was dependent on.
回答4:
The solution for me was based on @Daniel's response. I started looking for a reference to a plugin that was trying to load but was not installed.
I was not doing any image uploading but I was trying to add a plugin that I had not installed. Specifically, it was: extraPlugins: 'tableresize',
I did not need tableresize
so I just removed the tableresize
from the extraPlugins
line. I reloaded the page and the error was gone.