php preg_replace help iframe src

He creado una función que establecerá alto, ancho y wmode = transparente para los códigos de inserción de youtube. Ahora YouTube está devolviendo el código del iframe. Por lo tanto, necesito agregar "? Wmode = transparent" al final de youtube src.

Por ejemplo,
Código original:

<iframe title = "Reproductor de video de YouTube" width = "420" height = "349" src = "http://www.youtube.com/embed/aXNUL1-urg8" frameborder = "0" allowfullscreen = ""> < / iframe>

Quiero que se reemplace con:

<iframe title = "Reproductor de video de YouTube" ancho = " mywidth "height ="mi altur "src =" http://www.youtube.com/embed/aXNUL1-urg8? wmode = transparente "frameborder =" 0 "allowfullscreen =" "> </iframe>

Reemplazar alto y ancho funciona, pero reemplazar src no funciona.

Estoy usando a continuación regex

$ patterns [] = '/src="http:\/\/www.youtube.com\/embed\/[a-zA-Z0-9._-font>"/'
$ reemplazos [] = 'src = "http://www.youtube.com/embed/${1}?wmode=transparent"';

Abajo está mi función.

function SetHeightWidthVideo ($ markup, $ w = '200', $ h = '120') {// para que sea wmode = transparent

  $markup = str_replace('<embed ','<embed wmode="transparent" ',$markup);
  //$w = '200';
  //$h = '120';

  $patterns = array();
  $replacements = array();
  if( !empty($w) )
  {
      $patterns[] = '/width="([0-9]+)"/';
      $patterns[] = '/width:([0-9]+)/';

      $replacements[] = 'width="'.$w.'"';
      $replacements[] = 'width:'.$w;
  }

  if( !empty($h) )
  {
      $patterns[] = '/height="([0-9]+)"/';
      $patterns[] = '/height:([0-9]+)/';

      $replacements[] = 'height="'.$h.'"';
      $replacements[] = 'height:'.$h;
  }



  $patterns[] = '/src="http:\/\/www\.youtube\.com\/embed\/[a-zA-Z0-9._-]"/';
  $replacements[] = 'src="http://www.youtube.com/embed/${1}?wmode=transparent"';

  return preg_replace($patterns, $replacements, $markup);

}

Por favor ayuda. Gracias por adelantado

Respuestas a la pregunta(2)

Su respuesta a la pregunta