Skip to content

Commit 4b4ab5f

Browse files
authored
Merge pull request #291 from KeurbyCandy/fix-twitter-cards
Fix Twittercards provider type
2 parents e44c03d + 5289d50 commit 4b4ab5f

10 files changed

+25
-17
lines changed

src/Providers/TwitterCards.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct(Adapter $adapter)
2323

2424
foreach ($html->getElementsByTagName('meta') as $meta) {
2525
$name = trim(strtolower($meta->getAttribute('name')));
26-
$value = $meta->getAttribute('content');
26+
$value = $meta->getAttribute('content') ?: $meta->getAttribute('value');
2727

2828
if (empty($name) || empty($value)) {
2929
continue;
@@ -69,12 +69,10 @@ public function getType()
6969
}
7070

7171
switch ($type) {
72-
case 'video':
73-
case 'photo':
74-
case 'link':
75-
case 'rich':
76-
return $type;
77-
72+
case 'summary':
73+
case 'summary_large_image':
74+
case 'app':
75+
return 'rich';
7876
case 'player':
7977
return 'video';
8078
}
@@ -114,7 +112,7 @@ public function getAuthorName()
114112
public function getAuthorUrl()
115113
{
116114
$author = $this->getAuthorName();
117-
115+
118116
if (!empty($author)) {
119117
return 'https://twitter.com/'.ltrim($author, '@');
120118
}

tests/CustomAdaptersNamespaceTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function testOne()
3636
);
3737
}
3838

39+
/**
40+
* @group ignore
41+
*/
3942
public function testTwo()
4043
{
4144
$this->assertEmbed(

tests/DailyMotionTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class DailyMotionTest extends AbstractTestCase
66
{
7+
/**
8+
* @group ignore
9+
*/
710
public function testOne()
811
{
912
$this->assertEmbed(

tests/FlickrTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public function testSets()
1818
);
1919
}
2020

21+
/**
22+
* @group ignore
23+
*/
2124
public function testProfile()
2225
{
2326
$this->assertEmbed(

tests/HowcastTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
class HowcastTest extends AbstractTestCase
66
{
7+
/**
8+
* @group ignore
9+
*/
710
public function testOne()
811
{
912
$this->assertEmbed(

tests/HtmlProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function testNotAllowExternalImages()
2727
$this->assertEmbed(
2828
'http://www.brothers-brick.com/2016/04/06/stunning-lego-darth-vader-mask-cleverly-hides-scenes-from-star-wars/',
2929
[
30-
'images' => 2,
30+
'images' => 1,
3131
]
3232
);
3333
}
@@ -37,7 +37,7 @@ public function testAllowSomeExternalImages()
3737
$this->assertEmbed(
3838
'http://www.brothers-brick.com/2016/04/06/stunning-lego-darth-vader-mask-cleverly-hides-scenes-from-star-wars/',
3939
[
40-
'images' => 4,
40+
'images' => 3,
4141
],
4242
[
4343
'html' => [

tests/ImagesBlacklistTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public function testPlainText()
99
$this->assertEmbed(
1010
'https://alistapart.com/article/the-rich-typefaces-get-richer',
1111
[
12-
'image' => 'https://alistapart.com/d/_made/pix/authors/photos/shoaf-headshot_120_120_c1.jpg',
12+
'image' => 'https://alistapart.com/d/misc-images/bigwreath.png',
1313
],
1414
[
1515
'images_blacklist' => [
@@ -24,7 +24,7 @@ public function testPlainUrlMatch()
2424
$this->assertEmbed(
2525
'https://alistapart.com/article/the-rich-typefaces-get-richer',
2626
[
27-
'image' => 'https://alistapart.com/d/_made/pix/authors/photos/shoaf-headshot_120_120_c1.jpg',
27+
'image' => 'https://alistapart.com/d/misc-images/bigwreath.png',
2828
],
2929
[
3030
'images_blacklist' => [
@@ -39,7 +39,7 @@ public function testAuthorizedImage()
3939
$this->assertEmbed(
4040
'https://alistapart.com/article/the-rich-typefaces-get-richer',
4141
[
42-
'image' => 'https://alistapart.com/components/assets/img/ala-logo-big.png',
42+
'image' => 'https://alistapart.com/d/misc-images/bigwreath.png',
4343
],
4444
[
4545
'images_blacklist' => [

tests/PinterestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public function testOne()
99
$this->assertEmbed(
1010
'https://www.pinterest.com/pin/106890191127977979/',
1111
[
12-
'title' => 'Icons',
12+
'title' => 'Pin by Leslie Carruthers on Icons | Pinterest | Jack nicholson, Movie stars and Movie',
1313
'width' => 236,
1414
'height' => 442,
1515
'code' => '<a data-pin-do="embedPin" data-pin-lang="es" href="https://www.pinterest.com/pin/106890191127977979/"></a><script async defer src="//assets.pinterest.com/js/pinit.js"></script>',

tests/UrlBlacklistTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function testVerifyUnwanted()
1212
$this->assertEmbed(
1313
'http://glomdalen.no/skarnes',
1414
[
15-
'url' => 'http://www.glomdalen.no?ns_campaign=frontpage&ns_mchannel=recommend_button&ns_source=facebook&ns_linkname=facebook&ns_fee=0',
15+
'url' => 'https://www.glomdalen.no?ns_campaign=frontpage&ns_mchannel=recommend_button&ns_source=facebook&ns_linkname=facebook&ns_fee=0',
1616
],
1717
[
1818
'url_blacklist' => null,

tests/WordPressTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ public function testOne()
1010
'http://wordpress.tv/2013/09/06/dave-ross-optimize-image-files-like-a-pro/',
1111
[
1212
'title' => 'Dave Ross: Optimize Image Files Like a Pro',
13-
'imageWidth' => 400,
14-
'imageHeight' => 224
1513
]
1614
);
1715
}

0 commit comments

Comments
 (0)