godaddy-wordpress / primer

Primer is a powerful theme that brings clarity to your content in a fresh design. This is the parent for all themes in the GoDaddy Primer theme family.
https://wordpress.org/themes/primer/
GNU General Public License v2.0
134 stars 36 forks source link

Add theme support for AMP compatibility with official plugin #288

Closed westonruter closed 5 years ago

westonruter commented 5 years ago

Fixes #77.

This adds amp theme support for the official AMP plugin. The existing theme templates and styles are used, but places where JS was used are replaced with the AMP equivalents.

The remaining item to do is to fix the header video when YouTube is used, but this depends on an upstream change to AMP itself: https://github.com/ampproject/amp-wp/pull/2642.

westonruter commented 5 years ago

In regards to the video header, I tried using an MP4 on the non-AMP version and it seemed broken:

image

The video file (VID_20190510_140903.mp4.zip) looks like this:

image

So I was expecting to see the bridge, not just the top-left corner of the sky. I also didn't expect to see a black margin on the left. So in a6104c3 I fixed what appeared to be a bug with the layout a header video element, and added AMP compat.

Non-AMP

image

AMP

image


Aside: This also unveiled a bug with the AMP plugin's general handling of video headers, in that the loop attribute was failing to be added:

--- a/includes/class-amp-theme-support.php
+++ b/includes/class-amp-theme-support.php
@@ -2408,7 +2408,8 @@ class AMP_Theme_Support {
                array_merge(
                    $video_attributes,
                    array(
-                       'src' => $video_settings['videoUrl'],
+                       'src'  => $video_settings['videoUrl'],
+                       'loop' => '',
                    )
                )
            );

I also noticed another issue with the AMP plugin where if you do not supply a header image at all, then a selected video does not render. For AMP fixes to these issues, see https://github.com/ampproject/amp-wp/pull/2642.

westonruter commented 5 years ago

Great. When should this be released on WordPress.org?

EvanHerman commented 5 years ago

@westonruter

This was rolled into the 1.8.7 release which has been available on WordPress.org for the last two hours.