PluginProbe
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.9.9
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.9.9
4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 All 189 releases
embedpress / vendor / wpdevelopers / embera / src / Embera / Provider / Loom.php
Loom.php
90 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Loom.php
5 *
6 * @package Embera
7 * @author Andrew Minion
8 * @link https://andrewrminion.com/
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
12 */
13
14 namespace Embera\Provider;
15
16 use Embera\Url;
17
18 /**
19 * loom.com Provider
20 * @link https://www.loom.com
21 */
22 class Loom extends ProviderAdapter implements ProviderInterface
23 {
24 /** inline {@inheritDoc} */
25 protected $endpoint = 'https://www.loom.com/v1/oembed/';
26
27 /** inline {@inheritDoc} */
28 protected static $hosts = [
29 'loom.com', 'www.loom.com',
30 ];
31
32 /** inline {@inheritdoc} */
33 protected $allowedParams = [ 'maxwidth', 'maxheight' ];
34
35 /** inline {@inheritdoc} */
36 protected $httpsSupport = true;
37
38 /** inline {@inheritdoc} */
39 protected $responsiveSupport = false;
40
41 /** inline {@inheritDoc} */
42 public function validateUrl(Url $url)
43 {
44 return (bool) preg_match('~loom.com\/[share|embed]+\/([a-z0-9]+)~i', (string) $this->url);
45 }
46
47 /** inline {@inheritDoc} */
48 public function normalizeUrl(Url $url)
49 {
50 if (preg_match('~loom.com\/embed\/([a-z0-9]+)~i', (string) $url, $matches)) {
51 $url->overwrite('https://www.loom.com/share/' . $matches[1]);
52 }
53
54 return $url;
55 }
56
57 public function getFakeResponse()
58 {
59 preg_match('~loom.com\/share\/([a-z0-9]+)~i', (string) $this->url, $matches);
60 $id = $matches[1];
61
62 $embedUrl = 'https://www.loom.com/embed/'.$id;
63
64 $attr = [
65 'src="'.$embedUrl.'"',
66 'frameborder="0"',
67 'width="{width}"',
68 'height="{height}"',
69 'webkitallowfullscreen',
70 'mozallowfullscreen',
71 'allowfullscreen',
72 ];
73
74 return [
75 'type' => 'video',
76 'version' => '1.0',
77 'html' => '<iframe '.implode(' ', $attr).'></iframe>',
78 'title' => 'Untitled Video',
79 'height' => 960,
80 'width' => 1280,
81 'provider_name' => 'Loom',
82 'provider_url' => 'https://www.loom.com',
83 'thumbnail_height' => 960,
84 'thumbnail_width' => 1280,
85 'thumbnail_url' => 'https://cdn.loom.com/sessions/thumbnails/'.$id.'-00001.png',
86 'duration' => 0,
87 ];
88 }
89 }
90