Social marketing and youtube - solution

I had an issue with the Social Marketing plugin sitting behind my youtube videos. I found this solution online and thought it would be useful to share here.

Add the following to your function.php file

function add_video_wmode_transparent($html, $url, $attr) {
   if (strpos($html, "<iframe title=" ) !== false) {
    	$search = array('" frameborder="0"', '?hd=1?hd=1');
		$replace = array('?hd=1&wmode=transparent" frameborder="0"', '?hd=1');
		$html = str_replace($search, $replace, $html);

   		return $html;
   } else {
        return $html;
   }
}
add_filter('the_content', 'add_video_wmode_transparent', 10, 3);