Skip to content

Commit

Permalink
Prevent suppressing inject_video_max_width_style if not in AMP endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Feb 3, 2018
1 parent 2e197d3 commit a6e7c36
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-video-sanitizer.php
Expand Up @@ -125,7 +125,7 @@ public function sanitize() {
*/
private function filter_attributes( $attributes ) {
$out = array();
$out['style'] = 'max-width:100%';
$out['style'] = 'max-width:100%'; // Note that this will get moved to amp-custom style by AMP_Style_Sanitizer.

foreach ( $attributes as $name => $value ) {
switch ( $name ) {
Expand Down
5 changes: 4 additions & 1 deletion includes/widgets/class-amp-widget-media-video.php
Expand Up @@ -22,7 +22,10 @@ class AMP_Widget_Media_Video extends WP_Widget_Media_Video {
* @return string HTML Output.
*/
public function inject_video_max_width_style( $html ) {
return $html;
if ( is_amp_endpoint() ) {
return $html;
}
return parent::inject_video_max_width_style( $html );
}

}
Expand Down
5 changes: 4 additions & 1 deletion includes/widgets/class-amp-widget-text.php
Expand Up @@ -22,7 +22,10 @@ class AMP_Widget_Text extends WP_Widget_Text {
* @return string $html The markup, unaltered.
*/
public function inject_video_max_width_style( $matches ) {
return $matches[0];
if ( is_amp_endpoint() ) {
return $matches[0];
}
return parent::inject_video_max_width_style( $matches );
}

}
Expand Down
1 change: 1 addition & 0 deletions tests/test-class-amp-widget-text.php
Expand Up @@ -42,6 +42,7 @@ public function setUp() {
* @covers AMP_Widget_Text::inject_video_max_width_style()
*/
public function test_inject_video_max_width_style() {
add_theme_support( 'amp' );
$video = '<video src="http://example.com" height="100" width="200"></video>';
$video_only_width = '<video src="http://example.com/this-video" width="500">';
$this->assertEquals( $video, $this->widget->inject_video_max_width_style( array( $video ) ) );
Expand Down

0 comments on commit a6e7c36

Please sign in to comment.