Last active
February 8, 2018 17:31
-
-
Save hearvox/098774e9887442d39ddc6e34bedb10b1 to your computer and use it in GitHub Desktop.
Customizations for default WordPress audio shortcode and embed.
This file contains 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 | |
/** | |
* Change attribute for WP audio shortcode and embed. | |
* | |
* Default preload attribute is 'none' which shows time as 'O:OO'. | |
* Setting attribute to 'metadata' displays time upon page load. | |
* | |
* @param string $html Default audio shortcode HTML output. | |
* @return string $html Filtered audio shortcode HTML output. | |
*/ | |
function my_audio_preload( $html, $atts, $audio, $post_id, $library ) { | |
$html = str_replace( 'preload="none"', 'preload="metadata"', $html ); | |
return $html; | |
} | |
add_filter( 'wp_audio_shortcode', 'my_audio_preload', 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment