Skip to content

Instantly share code, notes, and snippets.

@Clorith
Last active August 29, 2015 14:00
Show Gist options
  • Save Clorith/11206952 to your computer and use it in GitHub Desktop.
Save Clorith/11206952 to your computer and use it in GitHub Desktop.
Make WordPress embeds of local content responsive
<?php
/**
* Filter function, converts fixed width to '100%' width
*/
function responsive_wp_video_shortcode( $html, $atts, $video, $post_id, $library ) {
$replace_value = array(
'width: ' . $atts['width'] . 'px'
);
$replace_with = array(
'width: 100%'
);
return str_ireplace( $replace_value, $replace_with, $html );
}
add_filter( 'wp_video_shortcode', 'responsive_wp_video_shortcode', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment