Skip to content

Instantly share code, notes, and snippets.

@nash-ye
Last active December 11, 2016 00:11
Show Gist options
  • Save nash-ye/43f2e5d1633c50226cafc55bf0a0fa28 to your computer and use it in GitHub Desktop.
Save nash-ye/43f2e5d1633c50226cafc55bf0a0fa28 to your computer and use it in GitHub Desktop.
(function($) {
'use strict';
$(function() {
$(document.body).one('click.add-media-button', '.insert-media', function(event) {
var orginalInsertCallback = wp.media.editor.insert;
wp.media.editor.insert = function(html) {
var image = $('img', $("<div>" + html + "</div>"));
if (! image.attr('alt')) {
var confirmed = confirm("An image without alternative text had been inserted!");
if (confirmed) {
orginalInsertCallback(html);
} else {
/*
* The media frame should be opened again, or something!
*/
}
} else {
orginalInsertCallback(html);
}
};
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment