Skip to content
This repository has been archived by the owner. It is now read-only.

Adding reporting for empty alt tags #160

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,9 @@ function cs_title_tag() {
add_theme_support( 'title-tag' );
}
}
?>

function report_blank_alt() {
mail('joshua.roy@uconn.edu', 'Empty Alt Tag', 'Image with empty alt tag found at '.$_POST['location'].' on image '.$_POST['image']);
}
add_action( 'wp_ajax_report_blank_alt', 'report_blank_alt' );
add_action( 'wp_ajax_nopriv_report_blank_alt', 'report_blank_alt' );
12 changes: 11 additions & 1 deletion js/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,18 @@ jQuery(document).ready(function($) {
$(e).after(block)
}
$('#page img').each(function(){
alt = $(this).attr('alt')
var alt = $(this).attr('alt')
if (undefined != alt){
if(alt.length == 0 && (undefined == $(this).attr('role') || $(this).attr('role')!='presentation')){
var data = {
'action': 'report_blank_alt',
'location': window.location.href,
'image': $(this).attr('src')
};
// We can also pass the url value separately from ajaxurl for front end AJAX implementations
jQuery.post(ajax_object.ajax_url, data, function(response) {
});
}
alt = alt.toLowerCase()
//console.log('alt='+alt)
if (alt.indexOf('.jpg') >= 0 || alt.indexOf('.png') >= 0 || alt.indexOf('.gif') >= 0 ){
Expand Down