Mini plugin to center Youtube iframes inserted with oEmbed in WordPress
<?php
/**
* @package Uploads_Media
* @version 0.1
* @see http://wordpress.stackexchange.com/a/50781/16301
*/
/*
Plugin Name: Center Youtube Iframe
Plugin URI: https://core.trac.wordpress.org/ticket/32920
Description: Wraps youtube iframe in a centered paragraph
Author: Jesus Franco
Version: 0.1
Author URI: https://tzkmx.wordpress.com/
*/
add_filter( 'embed_oembed_html', function( $cache, $url ) {
if( preg_match('/youtube.com/', $url) ) {
return '<p style="text-align:center;">' .$cache . '</p>';
}
return $cache;
}, 13, 2);