Info
Content

Werken met YouTube

Als u YouTube-video's in uw website insluit, moet u ervoor zorgen dat deze worden geblokkeerd als er geen toestemming wordt gegeven.

Opmerking: We raden aan om de "no-cookie-codes" van YouTube te gebruiken. Om dit te doen, vervangt u gewoon www.youtube.com in de <iframe ...> coderen met www.youtube-nocookie.com

Voorbeeldcode vóór wijzigingen:

<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/gHTrl91Rdls" 
        frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" 
        allowfullscreen></iframe>

Voorbeeldcode na wijzigingen:

<iframe data-cmp-vendor="s30" src="about:blank" class="cmplazyload" 
        width="560" height="315" 
        data-cmp-src="https://www.youtube-nocookie.com/embed/gHTrl91Rdls" frameborder="0" 
        allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" 
        allowfullscreen ></iframe>

Voor YouTube-video's die groter zijn dan 300 x 300 pixels, wordt de CMP automatisch toegepast dynamische inhoudsblokkering.

YouTube binnen Wordpress websites

Om de YouTube-embedcode aan te passen in een wordpress website kunt u het volgende gebruiken WordPress-Code (voeg deze toe aan de functies.php van uw WordPress ontwerpthema) om automatisch alle YouTube-video's op uw website op te maken:

// customize wordpress gutenberg's core youtube block
function cmp_youtube_player($block_content, $block)
{
	if ("core/embed" === $block['blockName'] && "youtube" === $block['attrs']['providerNameSlug']) {
		$block_content = str_replace('?feature=oembed', '?feature=oembed&rel=0', $block_content);
		$block_content = str_replace(' src="https://www.youtube.com/', ' src="about:blank" data-cmp-src="https://www.youtube-nocookie.com/', $block_content);
        $block_content = str_replace(' src="https://www.youtube-nocookie.com/', ' src="about:blank" data-cmp-src="https://www.youtube-nocookie.com/', $block_content);
		$block_content = str_replace('<iframe ', '<iframe data-cmp-vendor="s30" class="cmplazyload" ', $block_content);
	}
	return $block_content;
}
add_filter('render_block', 'cmp_youtube_player', 10, 2);

Terug naar boven