1(function($, Proud) { 2 3 /** 4 * Forces alt text on image insert 5 */ 6 7 $(document).ready( function(){ 8 9 // Extend the WP backbone model for the image button 10 if (window.wp && window.wp.media && window.wp.media.view && window.wp.media.view.Button) { 11 window.wp.media.view.Button = window.wp.media.view.Button.extend({ 12 // Save orig 13 oldInitialize: window.wp.media.view.Button.prototype.initialize, 14 // Add our click processing 15 click: function(event){ 16 // In insert mode 17 if (this.$el.hasClass('media-button-insert') || this.$el.hasClass('media-button-select')) { 18 // Check if alt has value 19 var $alt = $('[data-setting="alt"] input:visible'); 20 if ($alt.length && !$alt.val()) { 21 // Make input obvious 22 $alt.css({ 'border-color': 'red' }) 23 // Make label red, add required 24 $alt.siblings('label, span') 25 .css({ color: 'red' }) 26 .append('<abbr class="required">*</abbr>'); 27 // Append msg 28 $alt.after( 29 $('<p class="help-block">See <a href="http://webaim.org/techniques/alttext/" target="_blank">this for more information</a>.</p>') 30 .css({ 31 clear: 'both', 32 color: 'red', 33 float: 'right', 34 width: '65%', 35 }) 36 ); 37 alert('Please provide the "alt" text for the image.') 38 event.preventDefault(); 39 return false; 40 } 41 } 42 this.oldClick(event); 43 }, 44 // Save orig 45 oldClick: window.wp.media.view.Button.prototype.click, 46 }); 47 } 48 }); 49})(jQuery, Proud);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.