Skip to content

Instantly share code, notes, and snippets.

@hearvox
Last active February 8, 2018 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hearvox/098774e9887442d39ddc6e34bedb10b1 to your computer and use it in GitHub Desktop.
Save hearvox/098774e9887442d39ddc6e34bedb10b1 to your computer and use it in GitHub Desktop.
Customizations for default WordPress audio shortcode and embed.
<?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