One of my users used an external image service to post images of maths formulas. Problem: As soon as the image service goes offline, images are lost. So: How to force users to upload images?
The solution I implemented: Hide the image info tab so that the user cannot specify an external URL. Only show the tab of the image upload.
To do this you need to change the qa-plugin/wysiwyg-editor/image.js:
Insert directly after I.preview.setStyle('display','none');}
these lines:
this.selectPage('Upload'); this.hidePage('info'); document.getElementById(this.getButton('ok').domId).style.display='none';
Effect: Upload tab is selected first, Image Info tab is hidden, OK-button of main dialog is hidden.
We show the OK-button again, don't worry, after the user has uploaded an image, using qa-plugin/wysiwyg-editor/config.js
In:
CKEDITOR.on( 'dialogDefinition', function( ev ) {
//... some code here (see post)
else if(dialogName == 'image') {
// ... remove stuff
dialogDefinition.onLoad = function () {
// add:
// on tab switching or automatic after upload
this.on('selectPage', function (e) {
// hack to reference and show OK button
document.getElementById(this.getButton('ok').domId).style.display='inline';
// after upload the selectPage event is fired, show Image Info
dialog.showPage( 'info' );
});
};
}
I hope that "tiny tutorial" can help :)