Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( ! function_exists( 'videotube_instagram_aspect_ratio' ) ){
- /**
- * @param unknown_type $aspect_ratio
- * @return unknown|string
- */
- function videotube_instagram_aspect_ratio( $aspect_ratio ) {
- $url = $host = '';
- // Get the object from post meta.
- $object = get_post_meta( get_the_ID(), 'video_url', true );
- if( empty( $object ) ){
- return $aspect_ratio;
- }
- $url = parse_url( $object );
- if( isset( $url['host'] ) && ! empty( $url['host'] ) ){
- $host = preg_replace('/^www\./', '', $url['host'] );
- }
- if( isset( $host ) && ! empty( $host ) ){
- if( in_array( $host , array( 'instagram.com', 'twitter.com' ) ) ){
- $aspect_ratio = 'embed-responsive-' . esc_attr( $host );
- }
- }
- if ( preg_match('/twitter.com/', $object ) ){
- $aspect_ratio = 'embed-responsive-twitter';
- }
- return $aspect_ratio;
- }
- add_filter( 'aspect_ratio' , 'videotube_instagram_aspect_ratio', 100, 1 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement