if ( empty( $src ) ) { return;
} $youtube_pattern = '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#';
$vimeo_pattern = '#^https?://(.+\.)?vimeo\.com/.*#';
if ( $attachment ||
preg_match( $youtube_pattern,
$src ) ||
preg_match( $vimeo_pattern,
$src ) ) { add_filter( 'wp_video_shortcode', array
( $this, 'inject_video_max_width_style'
) );
echo wp_video_shortcode( array_merge( $instance,
compact( 'src'
) ),
$instance['content'
] );
remove_filter( 'wp_video_shortcode', array
( $this, 'inject_video_max_width_style'
) );
} else { echo $this->
inject_video_max_width_style( wp_oembed_get( $src ) );
} }