Created
January 31, 2017 23:51
-
-
Save tzkmx/215cf5537b7aee83d85c189ea744f2cf to your computer and use it in GitHub Desktop.
Mini plugin to center Youtube iframes inserted with oEmbed in WordPress
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 | |
/** | |
* @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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment