• Resolved technocombo

    (@technocombo)


    If I open the chrome console, a message shows up, “Invalid <amp-iframe> src. Must start with https://&#8221;. On investigating, I found out that AMP is not adding src. I am using youtube iframe and no doubt, youtube URL goes with https. So, how to fix this?

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

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter technocombo

    (@technocombo)

    Someone help.

    Plugin Author Weston Ruter

    (@westonruter)

    @technocombo How are you embedding the YouTube video? You should be using an oEmbed instead of adding a raw iframe in your post content. To add an oEmbed, just paste the URL to the video on a paragraph by itself.

    Nevertheless if the URL starts with https:// it should not get stripped.

    Note also the removal of src being a problem here: https://github.com/Automattic/amp-wp/issues/938

    Plugin Author Weston Ruter

    (@westonruter)

    @technocombo Please share the iframe code from your underlying post_content.

    Thread Starter technocombo

    (@technocombo)

    Sorry for replying late.

    Here’s the iframe code:
    <iframe width=”560″ height=”315″ frameborder=”0″ allowfullscreen=”allowfullscreen” src=”https://www.youtube.com/embed/BLgNbncE3E0″></iframe&gt;

    Even though the URL starts from https, the amp still strips https from the <amp-iframe>!
    Please help

    Thread Starter technocombo

    (@technocombo)

    Does oEmbed works on Facebook videos or Bitcoin charts?

    Because the problem is same for all. AMP automatically strips out the src from <amp-iframe> tag although using https

    Thread Starter technocombo

    (@technocombo)

    I updated the Permalinks. Forgot to say.

    The page I need help is:
    https://www.technocombo.com/2018/01/samsung-galaxy-s9-leaks/amp/

    Plugin Author Weston Ruter

    (@westonruter)

    In the non-AMP version I’m actually not seeing what you shared. I actually see:

    <iframe width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen" src="about:blank" data-rocket-lazyload="fitvidscompatible" data-lazy-src="https://www.youtube.com/embed/BLgNbncE3E0"></iframe><noscript><iframe width="560" height="315" frameborder="0" allowfullscreen="allowfullscreen" src="https://www.youtube.com/embed/BLgNbncE3E0"></iframe></noscript>

    It seems this is actually a problem with the plugin “Lazy Load by WP Rocket”: https://github.com/wp-media/rocket-lazy-load/blob/c8af2e40fd346989c3376af6da7c22605ffb1a0e/rocket-lazy-load.php#L447-L527

    Try adding the following to your theme’s functions.php to disable the functionality when serving as AMP:

    add_filter( 'do_rocket_lazyload_iframes', function( $do_lazyload ) {
        if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
            $do_lazyload = false;
        }
        return $do_lazyload;
    } );
    Thread Starter technocombo

    (@technocombo)

    Thank you so much. That worked really well.

    P.S. For those who are getting this error “Uncaught DOMException: Failed to construct ‘PresentationRequest'”, make sure to add the following attribute to your iframe tag:
    sandbox=”allow-scripts allow-same-origin allow-presentation”

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘not adding src’ is closed to new replies.