Support

Account

Home Forums ACF PRO Change oEmbed youtube URL

Solving

Change oEmbed youtube URL

  • Hello,

    With the new GDPR law you have to give users an option wich cookies they want to be placed or not.

    Youtube will place multiple marketing cookies when you embed a video. There is a way to avoid this. When you change the URL to “youtube-nocookie.com” it wont place a cookie.

    Is there a way to change the source “youtube.com” to “youtube-nocookie.com” with the advanced custom field oEmbed?

  • Hi @precies

    You can try this function to filter out the output: https://www.advancedcustomfields.com/resources/acf-render_field/

    This will allow you to replace the youtube.com string with the youtube-nocookie.com string. If you haven’t done that before, just look up “string replace php”

    Phil

  • Hello @nathanaelphilip

    I don’t really see how you can do it with the string replace php. Could you please help me on this matter?

    Thanks

  • Hey, did you find a solution for this?

  • <?php echo str_replace('https://www.youtube.com/embed', 'https://www.youtube-nocookie.com/embed', get_field('my_video')); ?>

  • Does not work for me. Not sure why this would be on render of the input (?) and not use update_value. I’ve posted as a separate question in General.

  • Putting something like this in the template is the best I could come up with:

    		<?php 
    			$iframe = get_field('video');
    			$iframe = str_replace('youtube.com/embed/', 'youtube-nocookie.com/embed/', $iframe);
    		?>
    
    		<div class="minus6db-video"><?php echo $iframe ?></div>
Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Change oEmbed youtube URL’ is closed to new replies.