Advertisement
Guest User

Untitled

a guest
Dec 4th, 2013
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  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();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement