Native video shortcode breaks video loading

[ad_1]

The query argument “_=” is often added to a video link to prevent caching and ensure that the latest version of the video is loaded each time the link is accessed. The argument makes the URL unique, tricking the browser into thinking it’s a new request and loading the updated content. This is especially useful when the video is frequently updated or changes often.

You can filter the output

wp_video_shortcode

add_filter(
	'wp_video_shortcode',
	function ( $output, $atts, $video, $post_id, $library ) {
		$output = preg_replace( '#^(.*?src=[^\?]*)(.*?)(".*$)#m', '$1$3', $output );

		return $output;
	},
	10,
	5
);

And yes – working out the regex is a pain but needed as the query arg valu ecan vary

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer