Videos will not worse anymore the performance if they load only after clicking on the play button.
Videos will not worse anymore the performance if they load only after clicking on the play button.
You can always add the provided shortcode, no matter which builder you are using. However, the actual version provides a full integration with the following builders (no need for the shortcode):
Shortcode name: load_video_on_click
Shortcode example:
[load_video_on_click link=”https://www.youtube.com/watch?v=AQ3FoNHC6SU” image_placeholder=”356″]
IF you embed a Youtube video and don’t set the image placeholder parameter, the plugin will get it directly from Youtube.
For the other video providers or if you self host the video file, you need to set the parameter image_placeholder, in another case people will only see a play button before loading the video.
If you use Gutenberg, the blocks Embed and Video will have the switch “Load on click”. Activate that switch to load the embedded video after clicking on the play button.
Don’t forget to set a Poster Image. It will be taken as placeholder before starting the video.
For any question or if something doesn’t work, don’t hesitate to open a thread on the support forum.
‘load_video_on_click_for_blocks’
It enables/disables the loading on click for existing videos added with the Video and Embed blocks (Gutenberg).
Example:
add_filter( 'load_video_on_click_for_blocks','__return_true' ); //It enables the loading on click for all videos added with the Video and Embed blocks
‘load_video_on_click_image_placeholder’
You can use it to replace the image placeholder.
Example:
add_filter( 'load_video_on_click_image_placeholder',function( $url,$attrs ){ //$attrs is the array of parameters in case of shortcode, and the block attributes in case of Gutenberg blocks if( false !== strpos( $url,'yout' ) ){ //Same image placeholder for all Youtube videos return wp_get_attachment_url( 2009 ); } return $url; },2,20 );
*Fix: stripped curly double-quotes when shortcode copied by the WordPress plugin page
*Fix: solved conflict with Real Cookie Banner
*Fix: displayed only first video
*Added: support to self hosted video
*Added: support to core/embed and core/video block
*Initial release