Skip to content

Commit

Permalink
fixed amp validation error with amp-facebook
Browse files Browse the repository at this point in the history
  • Loading branch information
ArroWsGM committed Feb 16, 2021
1 parent 14b8ec9 commit e8a0126
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AmpUtils/Sanitizers/FacebookSanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function create_amp_facebook_and_replace_node( $node, $embed_type ) {
'height' => $node->hasAttribute( 'data-height' ) ? $node->getAttribute( 'data-height' ) : $this->args['height'],
];

if ( '100%' === $attributes['width'] || 'auto' === $attributes['width'] ) {
if ( '100%' === $attributes['width'] || 'auto' === $attributes['width'] || '' === $attributes['width'] ) {
$attributes['layout'] = 'fixed-height';
$attributes['width'] = 'auto';
}
Expand Down
10 changes: 10 additions & 0 deletions tests/Feature/AmpSanitizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ public function testFbVideoAuto()
$this->assertEquals('<amp-facebook layout="fixed-height" width="auto" height="360" data-href="https://www.facebook.com/KOMONews/videos/225376735289463/" data-show-captions="false" data-embed-as="video"></amp-facebook>', $amp_content);
}

/**
* @group fb_test
*/
public function testFbVideoNoWidth()
{
$amp_content = Amped::convert('<div class="fb-video" data-href="https://www.facebook.com/KOMONews/videos/225376735289463/" data-width="" data-show-captions="false"></div>');

$this->assertEquals('<amp-facebook layout="fixed-height" width="auto" height="380" data-href="https://www.facebook.com/KOMONews/videos/225376735289463/" data-show-captions="false" data-embed-as="video"></amp-facebook>', $amp_content);
}

/**
* @group fb_test
*/
Expand Down

0 comments on commit e8a0126

Please sign in to comment.