This makes the alt text required in ckeditor and also adds Drupal's required span.
Created
January 8, 2015 16:42
-
-
Save awolfey/5db0c89ef98878d07e70 to your computer and use it in GitHub Desktop.
Make alternative text required in CKeditor image dialog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CKEDITOR.on('dialogDefinition', function(ev) { | |
var dialogName = ev.data.name; | |
var dialogDefinition = ev.data.definition; | |
var dialog = ev.data.definition.dialog; | |
switch (dialogName) { | |
case 'image': //Image Properties dialog | |
// Require alt text. | |
var altField = infoTab.get('txtAlt'); | |
altField.label = 'Alternative text <span class="form-required" title="This field is required.">*</span>'; | |
altField.validate = function() { | |
var alt = dialog.getContentElement('info', 'txtAlt'); | |
if (alt.getValue() == '') { | |
return "Alternative text is required."; | |
} | |
} | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for image2, just change 'image' to 'image2' and 'txtAlt' to 'alt'