Skip to content

Commit d154f5b

Browse files
committed
recovered flickr adapter because oembed doesn't work for all urls
1 parent 8449840 commit d154f5b

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/Adapters/Flickr.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Adapter provider more information from flickr
4+
*/
5+
namespace Embed\Adapters;
6+
7+
use Embed\Url;
8+
use Embed\Request;
9+
use Embed\Utils;
10+
11+
class Flickr extends Webpage implements AdapterInterface
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public static function check(Request $request)
17+
{
18+
return $request->match([
19+
'https://www.flickr.com/photos/*',
20+
]);
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function getCode()
27+
{
28+
$code = parent::getCode();
29+
30+
if (empty($code)) {
31+
$url = (new Url($this->request->getUrl()))
32+
->withAddedDirectory('player');
33+
34+
$code = Utils::iframe($url->getUrl(), $this->width, $this->height);
35+
}
36+
37+
return $code;
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function getWidth()
44+
{
45+
if (!parent::getCode()) {
46+
return 640;
47+
}
48+
}
49+
50+
/**
51+
* {@inheritdoc}
52+
*/
53+
public function getHeight()
54+
{
55+
if (!parent::getCode()) {
56+
return 425;
57+
}
58+
}
59+
60+
/**
61+
* {@inheritdoc}
62+
*/
63+
public function getProviderName()
64+
{
65+
return 'Flickr';
66+
}
67+
}

0 commit comments

Comments
 (0)