Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use intrinsic as default layout for video instead of responsive layout #6761

Merged
merged 1 commit into from
Dec 6, 2021

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Dec 4, 2021

Summary

When we first implemented the video sanitizer, we chose the responsive layout because intrinsic was not initially available. Support for the intrinsic layout was added to amp-video in ampproject/amphtml#28349, but we didn't make the same change to the video sanitizer since it didn't seem necessary, even though we do use intrinsic as the default layout in the image sanitizer. However, I found a reason why it is needed. Namely, when a video is set to align left or right, it fails to render as responsive:

Non-AMP AMP Before 👎 AMP After 👍
Screen Shot 2021-12-03 at 18 42 37 Screen Shot 2021-12-03 at 18 43 13 Screen Shot 2021-12-03 at 18 43 30

Here's the markup I'm testing with:

<!-- wp:video {"id":1690,"align":"center"} -->
<figure class="wp-block-video aligncenter" id="bard"><video controls src="https://wordpressdev.lndo.site/content/uploads/2013/12/2014-slider-mobile-behavior.mov"></video><figcaption>No align.</figcaption></figure>
<!-- /wp:video -->

<!-- wp:video {"id":1690,"align":"left"} -->
<figure class="wp-block-video alignleft" id="bard"><video controls src="https://wordpressdev.lndo.site/content/uploads/2013/12/2014-slider-mobile-behavior.mov"></video><figcaption>Align left</figcaption></figure>
<!-- /wp:video -->

<!-- wp:paragraph -->
<p>This is a paragraph with a video floated to the left!</p>
<!-- /wp:paragraph -->

<!-- wp:video {"id":1690,"align":"full"} -->
<figure class="wp-block-video alignfull" id="bard"><video controls src="https://wordpressdev.lndo.site/content/uploads/2013/12/2014-slider-mobile-behavior.mov"></video><figcaption>Full width</figcaption></figure>
<!-- /wp:video -->

Checklist

  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@westonruter westonruter added this to the v2.2 milestone Dec 4, 2021
@westonruter westonruter requested a review from delawski December 4, 2021 03:03
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2021

Plugin builds for 1a12630 are ready 🛎️!

Copy link
Collaborator

@delawski delawski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good and it works as advertised (see below in AMP Standard mode):

Screenshot 2021-12-06 at 15 04 08

@westonruter westonruter merged commit 0db59e7 into develop Dec 6, 2021
@westonruter westonruter deleted the update/video-intrinsic-layout branch December 6, 2021 15:35
@bartoszgadomski
Copy link
Contributor

When I copy-pasted the markup that @westonruter used, it ended up with this:

AMP disabled AMP enabled
Screenshot 2021-12-8 at 15 59 01 Screenshot 2021-12-8 at 15 58 40

However, when I uploaded custom video to media library and replaced it in post content, it was rendered correctly:

AMP disabled AMP enabled
Screenshot 2021-12-8 at 15 57 02 Screenshot 2021-12-8 at 15 57 29

To summarize:

  • if provided video link is invalid, AMP set static width:auto and height:400px CSS properties and render video incorrectly
  • if provided video link is valid, AMP render it correctly, but force the SSL, which ends up with errors on localhost (not sure if it's a bug or feature):

Screenshot 2021-12-8 at 15 51 43

So in regards to this ticket which is limited to setting the "intrinsic" layout instead of "responsive", this works as expected, so I'm gonna mark this ticket as QA-passed.

In regards to the two issues I've found, these probably needs their separate bug tickets, but can you confirm @westonruter that these behaviors are indeed not expected?

@westonruter
Copy link
Member Author

  • if provided video link is invalid, AMP set static width:auto and height:400px CSS properties and render video incorrectly

If the video is not in the media library, then it will use the fallback height of 400. So that seems correct.

  • if provided video link is valid, AMP render it correctly, but force the SSL, which ends up with errors on localhost (not sure if it's a bug or feature):

AMP requires HTTPS for videos, so if testing on an environment that doesn't have SSL then it would be expected that there would be loading errors.

@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes. Embeds Sandboxing Experiment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants