• Resolved Tina

    (@tinareisweb)


    Hi,
    I have Complianz installed on a site with Oxygenbuilder. After installation, cookie banner works fine but the blocking of YouTube embeds when consent has not been given is broken.

    It is loading the button to accept cookies and the placeholder image, but not the wrapper container around the iframe, which results in completely broken page.

    So instead of loading:

    <div class=”wp-block-embed__wrapper cmplz-placeholder-1 cmplz-blocked-content-container”>
    <iframe … with placeholder as background … >
    <button … for accepting cookies … >
    </div>

    It loads:

    <iframe … with placeholder as background … >
    <button … for accepting cookies … >

    without the container.

    Do you have an idea what the solution could be?

    Best,
    Tina

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Jarno Vos

    (@jarnovos)

    Hi @tinareisweb,

    Could you try wrapping your video in another pair of <div> tags?

    Example:

    <div><iframe width="560" height="315" src="https://www.youtube.com/embed/DhFmMMX45gw" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>

    Kind regards,
    Jarno

    Thread Starter Tina

    (@tinareisweb)

    Hi Jarno,

    Thanks for the quick reply! That does actually solve it, wow.

    However, it means editors have to use HTML block in the backend, insert iframe code, then insert <div> tags. They’re not too tech-savvy, that’s definitely not a workable solution for us.

    Is there a way to fix it without having to insert tags manually?

    Best,
    Tina

    Plugin Author Aert Hulsebos

    (@aahulsebos)

    Hi @tinareisweb,

    The HTML block is added to Oxygen builder? You could add the HTML block in another column/section (I don’t know how it is called in Oxygen builder), this will create a DIV as well.

    I have another solution with some Javascript to fix it for every video, but this is a bit technical and will add some weight to the website.

    regards Aert

    Thread Starter Tina

    (@tinareisweb)

    Hi,

    It’s not added in Oxygenbuilder, actually Oxygenbuilder is only doing the templates, but content is added in normal Gutenberg editor.

    The problem occurs with both the normal Gutenberg Youtube-block and the Gutenberg HTML block (for inserting iframe).

    So I’m not even sure the problem is caused by Oxygen because Oxygen is not touching the content of posts per se. I tried checking for JS/CSS conflicts but couldn’t find any. No caching plugins etc. are enabled.

    If there’s no other solution, I’d highly appreciate the JS snippet even if it adds weight to the site (I should be okay with the technical implementation), because we also have a ton of old posts that have video embeds and it would be a ton of work to go into each one and add a section/container for them! πŸ™‚

    Thank you for your quick responses,
    Tina

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    @tinareisweb

    Recently we added a new filter that also allows a server side, solution for this, which doesn’t affect website performance:

        /**
          * @param string $html
          *
          * @return string
          */
         function cmplz_add_div_iframe($html){
             return '<div>'.$html.'</div>';
         }
         add_filter( 'cmplz_iframe_html', 'cmplz_add_div_iframe' );

    You can add it as mu-plugin :https://complianz.io/adding-filters-with-mu-plugins-quick-easy/

    It will wrap each blocked iframe in a div.

    Thread Starter Tina

    (@tinareisweb)

    Hi, nice, thank you!

    Implemented as mu-plugin and it works for iframes.

    Two questions remain:

    1. The iframe has width=”560″ height=”315″, but Complianz calculates the placeholder to be 560 x 420px, which gives the placeholder an ugly border and causes a layout shift when users accept cookies. Can we fix it? See example on my site
    2. Can we make this code work for the Gutenberg YouTube block as well? On the example page, I have the same video embedded two times, one HTML block with iframe code and below a YouTube block. As you can see, there seem to be some conflicts, height for placeholder div is not calculated properly (is 0px), so the video is not visible.
    • This reply was modified 3 years, 3 months ago by Tina.
    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    I think there’s an issue with your html structure, because if I look in Complianz safe mode:
    https://relaunch.medien-weiter-bildung.de/testbeitrag-videos/?cmplz_safe_mode

    I can see the second video actually has a height of 0px, so is not visible. The placeholder just copies this behaviour.

    As for the placeholder image: the original image downloaded from youtube:
    https://relaunch.medien-weiter-bildung.de/wp-content/uploads/complianz/placeholders/youtube5uWxrjVSXDo-hqdefault.jpg

    Has the black bars in it. Maybe you can select a screenshot without the black borders?

    As an iframe may have different height/width combinations, the plugin will calculate height and width of the placeholder based on the image size that is downloaded. Then it is adjusted to the width and ratio of the current div container.

    As alternative, you can add some custom css to ensure the placeholder never is higher than the height of the video you have set:

    .cmplz-blocked-content-container {
        height: 310px;
        background-position: center;
    }
    Thread Starter Tina

    (@tinareisweb)

    Update for anyone struggling with this:

    @rogierlankhorst Your CSS solution didn’t work unfortunately, and I can’t change the HTML because it is the default Youtube embed block in Gutenberg, which I want to make usable for my non-tech savvy editors.

    The problem is the default CSS classes WordPress attaches to Youtube embeds. You have to disable the checkbox in block settings “scale for smaller devices”.

    Problem is just that then the video doesn’t scale on smaller devices πŸ˜‰ but I’m working on fixing that and will update here.

    Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Youtube Content Blocker broken’ is closed to new replies.