Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 4th, 2013  |  syntax: None  |  size: 1.33 KB  |  views: 42  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <iframe width="560" height="315" src="//www.youtube.com/embed/UPk1B1bxUPg" frameborder="0" allowfullscreen></iframe>
  2.        
  3. <iframe width="560" height="315" src="//www.youtube.com/embed/UPk1B1bxUPg/?wmode=transparent" frameborder="0" allowfullscreen></iframe>
  4.        
  5. $str = '<iframe width="560" height="315" src="//www.youtube.com/embed/UPk1B1bxUPg" frameborder="0" allowfullscreen></iframe>';
  6.  
  7. $dom = new DOMDocument();
  8. $dom->loadHTML($str);
  9. foreach($dom->getElementsByTagName('iframe') as $iframe) {
  10.     $src = $iframe->getAttribute('src');
  11.     $src .= '?wmode=transparent'; // use a regex for better results
  12.     $iframe->setAttribute('src', $src);
  13. }
  14.  
  15. echo $dom->saveHTML();
  16.        
  17. <?php
  18. $videoEmbedCode = '<iframe width="560" height="315" src="//www.youtube.com/embed/UPk1B1bxUPg" frameborder="0" allowfullscreen></iframe>';
  19. $appendString = '/?wmode=transparent';
  20.  
  21. /* Youtube video sticky menu overlap fix */
  22. $searchStartLen = strpos($videoEmbedCode, 'youtube');
  23. $searchEndLen = strpos($videoEmbedCode, '"', $searchStartLen);
  24. $newVideoEmbedCode = substr_replace($videoEmbedCode, $appendString, $searchEndLen, 0);
  25.  
  26. print $newVideoEmbedCode;
  27. ?>
  28.        
  29. $doc = new DOMDocument();
  30. $doc->loadHTML($your_html);
  31.  
  32. foreach($doc->getElementsByTagName('iframe') as $iframe)
  33. {
  34. $iframe->setAttribute("src",$iframe->getAttribute('src').'?wmode=transparent');
  35. }
  36.  
  37. echo $doc->saveHTML();