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 customizable width/height args on AMP_Twitter_Embed_Handler rather than literals/defaults #6510

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions includes/embeds/class-amp-twitter-embed-handler.php
Original file line number Diff line number Diff line change
@@ -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 ) {