• Hi!

    So I noticed that the amp iframe javascript extension is not always loaded. I need to force it, since I’m loading an iframe, and I need it on every page. So I added this to the HTML head of the AMP for WP options:
    <script custom-element=”amp-iframe” src=”https://cdn.ampproject.org/v0/amp-iframe-latest.js&#8221; async></script>

    In the pages where the script isn’t loaded by the plugin, it’s fine, but for the pages that load it automatically, I naturally get an error because it’s loaded twice. It’s not a problem now, but I get a warning that it will soon be a problem.

    Is there a way currently to make it load automatically? Please please help. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    So Is it the iframe or AMP-Iframe that you are inserting (also share the code if possible) and where exactly?

    So I will also try to re-create it and If the issue occurs which I am sure it will, then I will try to solve it and release immediately.

    Thread Starter daneloctober

    (@daneloctober)

    Hi Ahmed!

    Here’s the code I insert at the bottom of my pages:

    <amp-iframe width="200" height="300"
        sandbox="allow-scripts allow-same-origin allow-forms"
        layout="responsive"
        frameborder="0"
        src="https://youcanbefound.com/wp-content/js/thc_contact.html">
    	<amp-img layout = "fill" src = "/wp-content/uploads/2019/08/loading.gif" placeholder></amp-img>
    </amp-iframe>

    Now, in the past I didn’t use an image placeholder. So when pages were not long enough, the iframe doesn’t load, and the amp for wp plugin doesn’t load the amp iframe extension library (https://cdn.ampproject.org/v0/amp-iframe-latest.js). Now, since I added the placeholder, I don’t need the content requirement anymore. But it still won’t show because amp for wp doesn’t load the amp iframe extension library for all pages (I’m assuming it only loads it for pages with long enough content).

    So is there a way to have it load all the time? I have to force it now, but for pages that load it automatically, it loads twice.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    I understood your issue. We can definitely fix this but I just need one last answer:

    Where exactly are you inputting the code? (Classic Editor, Gutenberg code module, AMP page builder, Widget or somewhere else?)

    Kindly provide the screenshot of the input so I can be 100% accurate with the solution.

    Thread Starter daneloctober

    (@daneloctober)

    Hi Ahmed!

    I added the script via an action hook in functions.php:

    add_action('amp_post_template_above_footer','contact_form_code');
    
    function contact_form_code() {
    	$contactscript = '<amp-iframe width="200" height="300"
        sandbox="allow-scripts allow-same-origin allow-forms"
        layout="responsive"
        frameborder="0"
        src="https://youcanbefound.com/wp-content/js/thc_contact.html">
    	<amp-img layout = "fill" src = "/wp-content/uploads/2019/08/loading.gif" placeholder></amp-img>
    </amp-iframe>';
    
    	echo $contactscript;
    }
    

    Let me know if you need anything else.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Include Option to Include AMP-iframe Javascript Extension’ is closed to new replies.