I have a custom field where I define the Youtube Url as a string.
https://www.youtube.com/watch?v=3VqHtEF3LPE
This then becomes the src in my theme's shortcode:
<?php
$ysrc = get_field('fl_tube');
if($ysrc) :
$poster = wp_get_attachment_image_src( get_post_thumbnail_id( $entry_id ), 'entry-fullwidth', false );
echo do_shortcode( '[x_video_player src="' . $ysrc . '" poster="' . $poster[0] . '" preload="metadata" hide_controls="false" autoplay="false" loop="false" muted="false" no_container="true"]' );
?>
Wordpress renders this code and produces:
<div class="mejs-mediaelement">
<iframe class="me-plugin" id="me_youtube_0_container" frameborder="0" allowfullscreen="1" title="YouTube video player" width="480" height="270" src="https://www.youtube.com/embed/3VqHtEF3LPE?controls=0&wmode=transparent&enablejsapi=1&origin=https%3A%2F%2Fwww.mydomain.com&widgetid=1">
</iframe>
</div>
In order to hide relative videos and info, I need to append to the url in iframe src
:
&rel=0&showinfo=0
I cannot add this in my custom field string because then the iframe src
output displays erroneously as:
src="https://www.youtube.com/embed/3VqHtEF3LPE?rel=0?controls=0&wmode=transparent&enablejsapi=1&origin=https%3A%2F%2Fwww.mydomain.com&widgetid=1"
Is there a workaround using javascript or a function maybe to append &rel=0&showinfo=0
to the iframe src
for all youtube videos embedded on my site.