Skip to content

Commit a73a603

Browse files
committed
fixed other width/height issues, repaired tests
1 parent 1aadc57 commit a73a603

13 files changed

+82
-21
lines changed

src/Adapters/Adapter.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ public function getSource()
215215
*/
216216
public function getCode()
217217
{
218-
$allCodes = Utils::getData($this->providers, 'code');
219-
218+
$this->width = null;
219+
$this->height = null;
220220
$choosen = null;
221221

222-
foreach ($allCodes as $code) {
222+
foreach (Utils::getData($this->providers, 'code') as $code) {
223223
// <object> and <embed> codes have less priority
224224
if (strpos($code['value'], '</object>') !== false || strpos($code['value'], '</embed>') !== false) {
225225
if (empty($choosen)) {
@@ -237,9 +237,6 @@ public function getCode()
237237
break;
238238
}
239239

240-
$this->width = null;
241-
$this->height = null;
242-
243240
if ($choosen) {
244241
//get the width/height
245242
foreach ($choosen['providers'] as $provider) {
@@ -434,7 +431,7 @@ public function getImageHeight()
434431
*/
435432
public function getWidth()
436433
{
437-
$this->code;
434+
$this->__get('code');
438435

439436
return $this->width;
440437
}
@@ -444,7 +441,7 @@ public function getWidth()
444441
*/
445442
public function getHeight()
446443
{
447-
$this->code;
444+
$this->__get('code');
448445

449446
return $this->height;
450447
}

src/Adapters/File.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ public function getCode()
7171

7272
switch (self::$contentTypes[$this->request->getMimeType()][1]) {
7373
case 'videoHtml':
74-
return Utils::videoHtml($this->getImage(), $this->getUrl(), $this->getWidth(), $this->getHeight());
74+
return Utils::videoHtml($this->image, $this->url, $this->imageWidth, $this->imageHeight);
7575

7676
case 'audioHtml':
77-
return Utils::audioHtml($this->getUrl());
77+
return Utils::audioHtml($this->url);
7878

7979
case 'google':
80-
return Utils::google($this->getUrl());
80+
return Utils::google($this->url);
8181
}
8282
}
8383

@@ -86,10 +86,10 @@ public function getCode()
8686
*/
8787
public function getImagesUrls()
8888
{
89-
if ($this->getType() === 'photo') {
89+
if ($this->type === 'photo') {
9090
return [
9191
[
92-
'value' => $this->getUrl(),
92+
'value' => $this->url,
9393
'providers' => ['adapter'],
9494
],
9595
];

src/Adapters/Github.php

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ public function getUrl()
4747
*/
4848
public function getCode()
4949
{
50+
$this->width = null;
51+
$this->height = null;
52+
5053
if ($this->request->match('https://github.com/*/*/blob/*')) {
5154
$username = $this->request->getDirectoryPosition(0);
5255
$repo = $this->request->getDirectoryPosition(1);

src/Adapters/Google.php

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function run()
4040
*/
4141
public function getCode()
4242
{
43+
$this->width = null;
44+
$this->height = null;
45+
4346
if (($google = $this->getProvider('google'))) {
4447
return $google->getCode();
4548
}

src/Adapters/Howcast.php

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public static function check(Request $request)
2424
*/
2525
public function getCode()
2626
{
27+
$this->width = null;
28+
$this->height = null;
29+
2730
$dom = $this->request->getHtmlContent();
2831
$modal = $dom->getElementById('embedModal');
2932

src/Adapters/Jsfiddle.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ class Jsfiddle extends Webpage implements AdapterInterface
1414
*/
1515
public function getCode()
1616
{
17-
$url = $this->getUrl();
17+
$this->width = null;
18+
$this->height = null;
1819

20+
$url = $this->url;
1921
$embed_url = $url.((substr($url, -1) === '/') ? 'embedded/' : '/embedded/');
2022

2123
return Utils::iframe($embed_url);

src/Adapters/N500px.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,26 @@ public function getCode()
2929
if (is_numeric($this->request->getDirectoryPosition(1))) {
3030
return Utils::iframe($this->request->createUrl()->withDirectoryPosition(2, 'embed.html'), $this->width, $this->height);
3131
}
32+
}
3233

33-
return '';
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function getWidth()
38+
{
39+
if (is_numeric($this->request->getDirectoryPosition(1))) {
40+
return $this->imageWidth;
41+
}
42+
}
43+
44+
/**
45+
* {@inheritdoc}
46+
*/
47+
public function getHeight()
48+
{
49+
if (is_numeric($this->request->getDirectoryPosition(1))) {
50+
return $this->imageHeight;
51+
}
3452
}
3553

3654
/**

src/Adapters/Parleys.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,23 @@ public function getCode()
2626
{
2727
$id = $this->request->getDirectoryPosition(1);
2828

29-
return '<div data-parleys-presentation="'.$id.'" style="width:100%;height:300px"><script type = "text/javascript" src="//parleys.com/js/parleys-share.js"></script></div>';
29+
return '<div data-parleys-presentation="'.$id.'" style="width:'.$this->width.';height:'.$this->height.'px"><script type = "text/javascript" src="//parleys.com/js/parleys-share.js"></script></div>';
30+
}
31+
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function getWidth()
36+
{
37+
return '100%';
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function getHeight()
44+
{
45+
return 300;
3046
}
3147

3248
/**

src/Adapters/Pastebin.php

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public static function check(Request $request)
2525
*/
2626
public function getCode()
2727
{
28+
$this->width = null;
29+
$this->height = null;
30+
2831
$embed_url = 'http://pastebin.com/embed_iframe.php?i='.($this->request->getQueryParameter('i') ?: $this->request->getDirectoryPosition(0));
2932

3033
return Utils::iframe($embed_url);

src/Adapters/Spreaker.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,27 @@ public function getCode()
3737
->withQueryParameters([
3838
'autoplay' => 'false',
3939
'episode_id' => $id,
40-
]), '100%', 131, 'min-width:400px;border:none;overflow:hidden;');
40+
]), $this->width, $this->height, 'min-width:400px;border:none;overflow:hidden;');
4141
}
4242

4343
break;
4444
}
4545
}
4646
}
47+
48+
/**
49+
* {@inheritdoc}
50+
*/
51+
public function getWidth()
52+
{
53+
return '100%';
54+
}
55+
56+
/**
57+
* {@inheritdoc}
58+
*/
59+
public function getHeight()
60+
{
61+
return 131;
62+
}
4763
}

tests/ChirbitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public function testOne()
88
'http://chirb.it/7A9L9B',
99
[
1010
'title' => 'Chirbit [nvanderklippe] Encana conference call',
11-
'width' => 398,
11+
'width' => 320,
1212
'height' => 120,
1313
'type' => 'rich',
1414
'providerName' => 'Chirbit',

tests/FlickrTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testProfile()
2222
[
2323
'imageWidth' => 2048,
2424
'imageHeight' => 1454,
25-
'code' => '<iframe src="https://www.flickr.com/photos/desescribir/player" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:640px;height:425px;"></iframe>',
25+
'code' => '<iframe src="https://www.flickr.com/photos/desescribir/player" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:600px;height:400px;"></iframe>',
2626
'type' => 'rich',
2727
]
2828
);

tests/N23hqTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ public function testOne()
99
[
1010
'title' => 'På god väns inrådan kommer det även bultförband vid pilarna. Låter bra tycker jag. (Better safe than sorry)',
1111
'image' => 'http://www.23hq.com/16171062/16600737_ac392e8a4d667e4726fbafc8a21728d5_large.jpg',
12-
'width' => 756,
13-
'height' => 567,
12+
'imageWidth' => 756,
13+
'imageHeight' => 567,
1414
'type' => 'photo',
1515
'authorName' => 'Zzleeper',
1616
'providerName' => '23',

0 commit comments

Comments
 (0)