Skip to content

Commit

Permalink
Use customizable width/height args on AMP_Twitter_Embed_Handler rathe…
Browse files Browse the repository at this point in the history
…r than literals/defaults
  • Loading branch information
westonruter committed Aug 3, 2021
1 parent 22b3ccb commit 8b14b85
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions includes/embeds/class-amp-twitter-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 8b14b85

Please sign in to comment.