PluginProbe
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.4.4
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.4.4
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
93 lines 2.4 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 Provider
20 * Record and share video messages of your screen, cam, or both. Faster than typing an email or me...
21 *
22 * @link https://www.loom.com
23 *
24 */
25 class Loom extends ProviderAdapter implements ProviderInterface
26 {
27 /** inline {@inheritDoc} */
28 protected $endpoint = 'https://www.loom.com/v1/oembed/';
29
30 /** inline {@inheritDoc} */
31 protected static $hosts = [
32 'loom.com', 'www.loom.com',
33 ];
34
35 /** inline {@inheritdoc} */
36 protected $allowedParams = [ 'maxwidth', 'maxheight' ];
37
38 /** inline {@inheritdoc} */
39 protected $httpsSupport = true;
40
41 /** inline {@inheritdoc} */
42 protected $responsiveSupport = false;
43
44 /** inline {@inheritDoc} */
45 public function validateUrl(Url $url)
46 {
47 return (bool) preg_match('~loom.com\/[share|embed]+\/([a-z0-9]+)~i', (string) $this->url);
48 }
49
50 /** inline {@inheritDoc} */
51 public function normalizeUrl(Url $url)
52 {
53 if (preg_match('~loom.com\/embed\/([a-z0-9]+)~i', (string) $url, $matches)) {
54 $url->overwrite('https://www.loom.com/share/' . $matches[1]);
55 }
56
57 return $url;
58 }
59
60 public function getFakeResponse()
61 {
62 preg_match('~loom.com\/share\/([a-z0-9]+)~i', (string) $this->url, $matches);
63 $id = $matches[1];
64
65 $embedUrl = 'https://www.loom.com/embed/'.$id;
66
67 $attr = [
68 'src="'.$embedUrl.'"',
69 'frameborder="0"',
70 'width="{width}"',
71 'height="{height}"',
72 'webkitallowfullscreen',
73 'mozallowfullscreen',
74 'allowfullscreen',
75 ];
76
77 return [
78 'type' => 'video',
79 'version' => '1.0',
80 'html' => '<iframe '.implode(' ', $attr).'></iframe>',
81 'title' => 'Untitled Video',
82 'height' => 960,
83 'width' => 1280,
84 'provider_name' => 'Loom',
85 'provider_url' => 'https://www.loom.com',
86 'thumbnail_height' => 960,
87 'thumbnail_width' => 1280,
88 'thumbnail_url' => 'https://cdn.loom.com/sessions/thumbnails/'.$id.'-00001.png',
89 'duration' => 0,
90 ];
91 }
92 }
93