Created
September 23, 2018 18:20
-
-
Save tripflex/86b03f93dfd412d5447a5f44d3dba593 to your computer and use it in GitHub Desktop.
Show small SoundCloud oEmbed player output in WordPress (visual=false)
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 | |
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