Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created September 23, 2018 18:20
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 tripflex/86b03f93dfd412d5447a5f44d3dba593 to your computer and use it in GitHub Desktop.
Save tripflex/86b03f93dfd412d5447a5f44d3dba593 to your computer and use it in GitHub Desktop.
Show small SoundCloud oEmbed player output in WordPress (visual=false)
<?php
add_filter( 'oembed_dataparse', 'smyles_soundcloud_oembed_show_small_player', 10, 3 );
function smyles_soundcloud_oembed_show_small_player( $html, $data, $url ) {
// Only process for soundcloud oembeds
if ( strpos( $url, 'soundcloud.com' ) === false ) {
return $html;
}
// Change visual from true to false (to display small player)
$html = str_replace( 'visual=true', 'visual=false', $html );
// Remove height from iframe tag (otherwise will show incorrect height for player)
$html = str_replace( ' height="383"', '', $html );
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment