Skip to content

Commit 05d6327

Browse files
committed
according to Twitter deprecated image width/src and gallery card
1 parent 1cb4afc commit 05d6327

1 file changed

Lines changed: 9 additions & 39 deletions

File tree

src/Services/Meta.php

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ class Meta extends Fluent implements ServiceInterface
5050
// twitter
5151
public string $twitter_card = 'summary'; //summary_large_image
5252
public string $twitter_creator;
53-
public string $twitter_image_src;
54-
public string $twitter_image_width;
55-
public string $twitter_image_height;
53+
public string $twitter_image;
5654
public string $twitter_player;
5755
public string $twitter_player_width;
5856
public string $twitter_player_height;
@@ -427,45 +425,17 @@ public function printTwitterTags()
427425
echo '<meta name="twitter:creator" content="@' . (strpos($this->twitter_creator, '@') === 0 ? substr($this->twitter_creator, 1) : $this->twitter_creator) . '">' . "\n";
428426
}
429427

430-
if ($this->twitter_card === 'gallery') {
431-
if (!empty($this->images)) {
432-
$i = 0;
433-
foreach ($this->images as $image) {
428+
if (!empty($this->twitter_image)) {
429+
echo '<meta name="twitter:image" content="' . $this->twitter_image . '">' . "\n";
430+
} elseif (!empty($this->images)) {
434431

435-
if (is_array($image)) {
436-
$url = $image['url'];
437-
} else {
438-
$url = $image;
439-
}
440-
echo '<meta name="twitter:image' . $i . ':src" content="' . $url . '">' . "\n";
441-
442-
if (++$i >= 4) {
443-
break;
444-
}
445-
}
446-
}
447-
} else {
448-
if (!empty($this->twitter_image_src)) {
449-
echo '<meta name="twitter:image:src" content="' . $this->twitter_image_src . '">' . "\n";
450-
} elseif (!empty($this->images)) {
451-
452-
if (is_array($this->images[0])) {
453-
$url = $this->images[0]['url'];
454-
} else {
455-
$url = $this->images[0];
456-
}
457-
458-
echo '<meta name="twitter:image:src" content="' . $url . '">' . "\n";
459-
}
460-
461-
//this should be auto anyway no? or maybe just remove it at all
462-
if (!empty($this->twitter_image_width)) {
463-
echo '<meta name="twitter:image:width" content="' . $this->twitter_image_width . '">' . "\n";
432+
if (is_array($this->images[0])) {
433+
$url = $this->images[0]['url'];
434+
} else {
435+
$url = $this->images[0];
464436
}
465437

466-
if (!empty($this->twitter_image_height)) {
467-
echo '<meta name="twitter:image:height" content="' . $this->twitter_image_height . '">' . "\n";
468-
}
438+
echo '<meta name="twitter:image" content="' . $url . '">' . "\n";
469439
}
470440

471441
// if (!empty($this->twitter_player))

0 commit comments

Comments
 (0)