79754890

Date: 2025-09-03 17:02:12
Score: 0.5
Natty:
Report link

9 years later in 2025

add_filter('oembed_result', function ($html, $url, $args) {
 if (strstr($html, 'youtube.com/embed/')) {
  $html = str_replace('?feature=oembed', '?feature=oembed&enablejsapi=1', $html);
 }
 return $html;
}, 10, 3);

works for just youtube videos,

you can then get the iframe like

const iframe = document.querySelectorAll("iframe");
if (iframe.contentWindow && iframe.src.startsWith("https://www.youtube.com")) { 
 iframe.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}',"*" ); 
}
Reasons:
  • Blacklisted phrase (1): youtube.com
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: adrock42