diff --git a/includes/embeds/class-amp-twitter-embed-handler.php b/includes/embeds/class-amp-twitter-embed-handler.php index e71dece6d8d..9dd030b5164 100644 --- a/includes/embeds/class-amp-twitter-embed-handler.php +++ b/includes/embeds/class-amp-twitter-embed-handler.php @@ -113,7 +113,9 @@ public function oembed_timeline( $matches ) { } } - $attributes['width'] = $this->args['width']; + if ( ! empty( $this->args['width'] ) ) { + $attributes['width'] = $this->args['width']; + } $attributes['height'] = $this->args['height']; if ( empty( $attributes['width'] ) || 'auto' === $attributes['width'] ) { $attributes['layout'] = 'fixed-height'; @@ -180,12 +182,17 @@ private function create_amp_twitter_and_replace_node( Document $dom, DOMElement return; } - $attributes = [ - 'width' => 'auto', - 'height' => $this->DEFAULT_HEIGHT, - 'layout' => 'fixed-height', - 'data-tweetid' => $tweet_id, - ]; + $attributes = []; + if ( ! empty( $this->args['width'] ) ) { + $attributes['width'] = $this->args['width']; + } + $attributes['height'] = $this->args['height']; + if ( empty( $attributes['width'] ) || 'auto' === $attributes['width'] ) { + $attributes['layout'] = 'fixed-height'; + } else { + $attributes['layout'] = 'responsive'; + } + $attributes['data-tweetid'] = $tweet_id; if ( $node->hasAttributes() ) { foreach ( $node->attributes as $attr ) {