Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #1073187

    Hi! There is a script in Enfold which turns the video links into lightbox popup, with embed code in it.
    How can I control the parameters of the embed?
    I would like to switch on the “Privacy Enhanced Mode” (it substitutes the youtube.com with youtube-nocookie.com)

    #1074222

    Hey Konstantin,

    There’s no option for that in Enfold.
    You’ll need to tweak avia-snippet-lightbox.js located in wp-content > themes > enfold > js folder.
    Then go to line 39:

    src: '//www.youtube.com/embed/%id%'

    then modify this url. Hope it helps.

    Best regards,
    Nikko

    #1074357

    Hi Nikko, thanks for your asnwer.
    Can this be done in the child theme? Or only in Enfold itself?

    #1074770

    Hi Konstantin,

    Try to copy avia-snippet-lightbox.js from the parent theme to the child theme’s js folder then in your child theme’s functions.php, add this code:

    function change_lightbox() {
      wp_dequeue_script( 'avia-lightbox-activation' );
      wp_enqueue_script( 'avia-lightbox-activation', get_stylesheet_directory_uri().'/js/avia-snippet-lightbox.js', array('avia-default'),2 ,true );
    }
    
    add_action( 'wp_enqueue_scripts', 'change_lightbox', 100 );

    Best regards,
    Nikko

    #1214122

    Hi Team,

    I also wanted the privacy enhanced mode for masonry gallery images with custom link to videos.
    I followed the instructions in
    https://kriesi.at/support/topic/open-youtube-videos-with-privacy-enhanced-mode/
    to the T.

    Added the mentioned script replacement in child theme functions.php.

    Changed line 39 in the avia-snippet-lightbox.js (copied to the child theme) to:

    src: '//www.youtube-nocookie.com/embed/%id%'

    but… the a href in the page source still shows:

    https://www.youtube.com/watch?v=

    when it should have become:

    https://www.youtube-nocookie.com/embed/

    Page cache and browser cache cleared many times, of course.

    No idea why this happens. Can you help me out?

    Thanks in advance.
    Rob

    • This reply was modified 4 years, 7 months ago by rob2701.
    #1214859

    Hi Rob,

    I apologize for the delayed response.
    Can you give us a link to the page mentioned? and if it’s possible to give us temporary admin access as well.
    Just post the login credentials in private content.

    Best regards,
    Nikko

    #1214958

    Hi Nikko,

    Thanks for looking into this. Details in private field.

    Kind regards,

    Rob

    #1216226

    Hi Rob,

    I apologize for the delayed response.
    Can you try to modify directly from avia-snippet-lightbox.js in the parent theme? and check if it works.

    Best regards,
    Nikko

    #1216259

    Hi Nikko,

    I updated the theme to 4.7.5 (thanks for the update, Team!)
    Commented out (in the child theme functions.php )the code switcher you provided above for using avia-snippet-lightbox.js in child theme instead of the parent theme one
    Modified avia-snippet-lightbox.js in the parent theme and saved
    Entered additional video (just to make sure nothing was cached somewhere in the database) using
    https://www.youtube.com/watch?v=

    Result is the same, the standard youtube link is NOT replaced with the youtube-nocookie link in the page source

    The temp login credentials I put in private field earlier are still valid, if you want to take a look. I have left things like I described above.

    Kind regards,
    Rob

    • This reply was modified 4 years, 7 months ago by rob2701. Reason: some typo and grammar fixes
    #1216627

    Hi Rob,

    Overriding avia-snippet-lightbox.js does not work on my end but the directly modifying from the Enfold theme does work on my end.
    Can you try to disable Javascript file merging and compression in Enfold > Performance?

    Best regards,
    Nikko

    #1216677

    Hi Nikko,

    Does not work for me, not even in parent theme and with js file merging and compression turned off.
    Same result: still the standard youtube link in the page source.
    Feel free to try it out on this development site, it’s a copy and well backed up. You have the link.
    Thanks for your time.

    Regards,
    Rob

    Additional info:
    Updated child theme header.php to reflect 4.7.5 changes, just to make sure. Everything left to NOT use the child theme lightbox.js but made the change in the parent theme. Same result, no replacement of youtube URL in page source.

    • This reply was modified 4 years, 7 months ago by rob2701. Reason: added additional info for clarity
    #1218307

    Hi Rob,

    I apologize for the delay but it has already worked on your site, you can refer to the iframe screenshot in private content.
    The link however in the masonry isn’t replaced to youtube-nocookie, replacing this won’t make the lightbox work.
    You can test this by adding this script:

    add_action('wp_footer', 'ytlinks_script');
    function ytlinks_script(){
    ?>
    <script>
        (function($)
        {	
            var ytlinks = document.querySelectorAll("a.isotope-item");
            var pattern = /youtube.com\/watch\?v=/ig;
    
            ytlinks.forEach(function(link) {
                var source = link.getAttribute("href").replace(pattern, "youtube-nocookie.com/embed/");
                link.setAttribute("href", source);
            });
        })(jQuery);
    </script>
    <?php
    }

    Best regards,
    Nikko

    #1218351

    Hi Nikko,

    Thanks for checking this and for clarifying the unchanged ahref links in the page source for me, I did not understand that until now.

    I see, so this last script for checking does the same as putting the format https://www.youtube-nocookie.com/embed/<VIDEO-ID> directly in the custom link for the image in the portfolio item?
    Indeed then the video does not open in a lightbox anymore but breaks out of the iframe. So, we can’t embed an iframe in a lightbox. Noted.

    Parent theme:
    I can confirm that when I put in the parent theme avia-snippet-lightbox.js, line 40:

    src: '//www.youtube-nocookie.com/embed/%id%?autoplay=0&ecver=2&showinfo=0&loop=1&rel=0&modestbranding=1&fs=0;'

    and enter the normal “https://www.youtube.com/watch?v=<VIDEO-ID>” in the custom link in the gallery image, then indeed the video is served from youtube-nocookie (cookie inspection with developer tools).

    I have done another test just now for the the replacement in the child theme (and of course adding your replacement script for avia-snippet-lightbox.js to the child theme functions.php) and now it seems that this also works, the video is served from the youtube-nocookie domain (cookie inspection with developer tools).
    Enabling or disabling javascript merge/compress in Enfold Performance does not seem to make a difference.
    I have no idea why the replacement in the child theme did not give that result the first times (in my tests and in yours).

    Can you doublecheck if it also works on your installation just to make sure that doing it in the child theme works consistently?

    function change_lightbox() {
      wp_dequeue_script( 'avia-lightbox-activation' );
      wp_enqueue_script( 'avia-lightbox-activation', get_stylesheet_directory_uri().'/js/avia-snippet-lightbox.js', array('avia-default'),2 ,true );
    }
    add_action( 'wp_enqueue_scripts', 'change_lightbox', 100 );

    Thanks for your time and help! Kind regards,

    Rob

    P.S.
    Obviously, if the same result is positive in your test with the child theme change, then please close this as solved.
    Thanks again for your support!

    Added information:
    Funny thing, on the live site I can only get this to work when setting the avia-snippet-lightbox.js changes in BOTH the parent theme and the child theme, while leaving the child theme replacement code for avia-snippet-lightbox.js intact.
    But I definitely ALWAYS have to re-save the Enfold child theme options to view the effect.
    Obviously making changes to the parent theme is not ideal, so I would appreciate if at some point you could come up with an explanation and a solution to only do it in the child theme.

    • This reply was modified 4 years, 6 months ago by rob2701. Reason: Added additional information after testing some more
    #1218573

    Hi Rob,

    You’re welcome, It does work for me when I tested but I have to change the name from avia-lightbox-activation to a different name, here’s the change I’ve made to make it work:

    function change_lightbox() {
      wp_dequeue_script( 'avia-lightbox-activation' );
      wp_enqueue_script( 'avia-lightbox-activation2', get_stylesheet_directory_uri().'/js/avia-snippet-lightbox.js', array('avia-default'),2 ,true );
    }
    
    add_action( 'wp_enqueue_scripts', 'change_lightbox', 100 );

    If I use the code I first gave you it will fetch from:
    http://mysite.com/wp-content/themes/enfold/js/avia-snippet-lightbox.js
    but using the code in this reply, I’m fetching from:
    http://mysite.com/wp-content/themes/enfold-child/js/avia-snippet-lightbox.js
    Seems weird because I have already dequeued it but I have tested it multiple times and get the same results.

    Best regards,
    Nikko

    #1218635

    Hi Nikko,

    That’s brilliant, what a good find!
    Tested on both dev and live, it works great, problem solved completely.

    Thanks again for the fix and for your help and great support!

    Kind regards, Rob

    #1218782

    Hi Rob,

    We’re glad that we could help :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 16 posts - 1 through 16 (of 16 total)
  • The topic ‘Open Youtube videos with Privacy Enhanced Mode’ is closed to new replies.