I need embed the thumbnail from a Youtube video and when I clic on the thumbnail the video start to play. I got the following php code (see php code below) where the video is embedded but I need the code where the thumbnail is embedded too and it starts to play when you clic on the thumnail. I think the code for the video to start playing is the below of the following one (see js code below).
PHP Code:
<?php
function mininaturas_youtube_func( $atts ) {
$a = shortcode_atts( array(
'id' => ''
), $atts);
return '<iframe width="560" height="315"
src="https://www.youtube.com/embed/' . $a["id"] . '" frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-
picture" allowfullscreen></iframe>';
}
add_shortcode( 'miniatura_youtube', 'mininaturas_youtube_func' );
?>
Js Code (my try):
$(document).ready(function(){
$("#play").click(function(){
$("#remove").hide();
$("#add").show();
});
});
Could you help to include the php code (into the PHP Code section) to embedded the thumbnail of the Youtube video and review the js code? Thanks