Fixed iframe support in AMP
authorAlexander Ebert <ebert@woltlab.com>
Wed, 5 Jul 2017 09:53:12 +0000 (11:53 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 5 Jul 2017 09:53:12 +0000 (11:53 +0200)
com.woltlab.wcf/templates/ampHeader.tpl
wcfsetup/install/files/lib/system/html/output/AmpHtmlOutputProcessor.class.php

index 75cfad20b58f749979d98b96774d7e2a43925b4f..064d449f67f245e7534e53bc38fc1ac1ca0326f7 100644 (file)
                <script async custom-element="amp-sidebar" src="https://cdn.ampproject.org/v0/amp-sidebar-0.1.js"></script>
                <script async custom-element="amp-user-notification" src="https://cdn.ampproject.org/v0/amp-user-notification-0.1.js"></script>
                <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
+               <script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
                <script async src="https://cdn.ampproject.org/v0.js"></script>
        </head>
 <body>
index 97bb5bf85955f4c559dee6d1f87a11d90b28556d..7115f35ca1a70086616dadf28a46b635c89d8bde 100644 (file)
@@ -101,7 +101,13 @@ class AmpHtmlOutputProcessor extends HtmlOutputProcessor {
         * @inheritDoc
         */
        public function getHtml() {
-               return str_ireplace('<img', '<amp-img layout="flex-item"', $this->getHtmlOutputNodeProcessor()->getHtml());
+               $html = $this->getHtmlOutputNodeProcessor()->getHtml();
+               
+               $html = str_ireplace('<img', '<amp-img layout="flex-item"', $html);
+               $html = str_ireplace('<iframe', '<amp-iframe layout="responsive" width="480" height="300" sizes="(min-width: 480px) 480px, 100vw" ', $html);
+               $html = str_ireplace('</iframe>', '<div class="wscIframePlaceholder" placeholder=""></div></amp-iframe>', $html);
+               
+               return $html;
        }
        
        /**