Skip to content

Commit 2bac4f0

Browse files
committed
Added Giphy adapter
1 parent 9c55421 commit 2bac4f0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Embed/Adapters/Giphy.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Adapter to get the embed code from giphy.com
4+
*/
5+
namespace Embed\Adapters;
6+
7+
use Embed\Viewers;
8+
use Embed\Request;
9+
10+
class Giphy extends Webpage implements AdapterInterface
11+
{
12+
/**
13+
* {@inheritDoc}
14+
*/
15+
public static function check(Request $request)
16+
{
17+
return $request->match(array(
18+
'https?://giphy.com/gifs/*'
19+
));
20+
}
21+
22+
23+
/**
24+
* {@inheritDoc}
25+
*/
26+
public function getCode()
27+
{
28+
if (($id = $this->request->getDirectory(1))) {
29+
return Viewers::iframe('//giphy.com/embed/'.$id, $this->width.'px', $this->height.'px');
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)