#In CKEditor, set the alt text value in the image dialog
It may not be a great idea to set the alt value to the image file name, but this can be modified to use some other value.
CKEDITOR.on('dialogDefinition', function(ev) { | |
var dialogName = ev.data.name; | |
var dialog = ev.data.definition.dialog; | |
switch (dialogName) { | |
case 'image': //Image Properties dialog | |
// Set the alt value to the image file name if it's left blank. | |
var urlField = infoTab.get('txtUrl'); | |
dialog.on('ok', function () { | |
var altField = dialog.getContentElement('info', 'txtAlt'); | |
if (altField.getValue() == '') { | |
var url = dialog.getContentElement('info', 'txtUrl').getValue() | |
altField.setValue(url.substring(url.lastIndexOf('/')+1)); | |
} | |
}); | |
break; | |
} | |
}); |