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

<?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>
The topic ‘Change oEmbed youtube URL’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.