Skip to content

Instantly share code, notes, and snippets.



Last active Oct 14, 2019
What would you like to do?
Prevent 'NotAllowedError' and 'user didn't interact with the document first' errors for Vimeo embedded in WordPress. No longer needed in WP 5.3 beta 3 or higher.
Add the code in the functions.php file below to your active theme's functions.php file.
You can remove the code once WordPress updates to media element 4.2.10+. (WordPress 5.3 beta 3 updated from 4.2.6 to 4.2.13:
add_action( 'wp_enqueue_scripts', 'studiopress_load_newer_vimeo_mediaelement', 100 );
* Replace the mediaelement-vimeo script with a newer version.
* This works around an issue in WordPress core that can prevent playback of
* Vimeo videos embedded via the `wp_video_shortcode()` function.
* This is caused by WordPress loading an older version of the Vimeo script
* (currently loads 4.2.6), which does not add the 'allow=autoplay'
* attribute to iframes that Chrome now requires to permit video playback as
* the first user action on a page.
* See
* This code and the `add_action` line above could be removed once WordPress
* updates to use Media Element 4.2.10+.
function studiopress_load_newer_vimeo_mediaelement() {
wp_dequeue_script( 'mediaelement-vimeo' );
wp_deregister_script( 'mediaelement-vimeo' );
array( 'mediaelement' ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.