Last active
May 18, 2017 12:33
-
-
Save BhargavBhandari90/7a28cc32f1c1b91ca250cd5b302004ed to your computer and use it in GitHub Desktop.
Remove title attribute from media page.
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
<?php | |
// Add this code to theme's functions.php | |
// Remove title attribute from media page. | |
// Check if function doest not exists. | |
if ( ! function_exists( 'rtmedia_wp_footer_remove_title' ) ) { | |
function rtmedia_wp_footer_remove_title() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
function remove_title() { | |
jQuery( '.rtmedia-container .rtmedia-list .rtmedia-list-item' ).each( function(){ | |
// Gets the title attribute | |
var title = jQuery( this ).find( '.rtmedia-list-item-a' ).attr( 'title' ); | |
if( title != 'undefined' ) { | |
// Make title attribute blank if found | |
jQuery( this ).find( '.rtmedia-list-item-a' ).attr( 'title', '' ); | |
} | |
}); | |
} | |
// Function for removing title attribute | |
remove_title(); | |
// Remove title attribute when new elements are added | |
jQuery('.rtmedia-list').bind("DOMSubtreeModified",function(){ | |
remove_title(); | |
}); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'wp_footer', 'rtmedia_wp_footer_remove_title' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment