Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1367577

    Hi, we integrated an iFrame in a code clock with a special feature for one of our customers. Unfortunately, this iFrame loads Google fonts, which is a GDPR problem. Can we integrate a custom cookie / service request via the Enfold cookie consent to deactivate / activate the iFrame (perhaps with a shortcode)?

    Thank you!
    Jan

    #1367756

    Hey Jan,

    Thank you for the inquiry.

    You can lazy load the iframe and only load it on user interaction. The example below loads a youtube video on click.

    
    function av_enable_iframe_on_interaction()
    {
        ?>
        <script type="text/javascript">
            (function($) {
                $(function() {
                    $('.av-enable-frame').click(function() {
                        var _this = $(this),
                            iframe = $('.av-custom-frame');
    
                        iframe.attr('src','https://www.youtube.com/embed/' + _this.attr('data-url'));
                    });
                });
            })(jQuery);
        </script>
        <?php
    }
    add_action( 'wp_footer', 'av_enable_iframe_on_interaction', 9999 );
    
    function av_enable_iframe_on_interaction_cb( $atts )
    {
        $frame  = '<div class="av-iframe-container">';
        $frame .= '<a class="av-enable-frame" href="#" data-url="hMxGhHNOkCU">Enable Iframe</a>';
        $frame .= '<iframe class="av-custom-frame" src="" width="560" height="315" frameborder="0" allowfullscreen></iframe>';
        $frame .= '</div>';
    
        return $frame;
    }
    add_shortcode( 'av_enable_iframe_on_int', 'av_enable_iframe_on_interaction_cb' );
    

    You can use this shortcode in a code or text block.

    [av_enable_iframe_on_int]
    

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.