PluginProbe
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 3.8.5
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v3.8.5
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 / Smugmug.php
Smugmug.php
69 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Smugmug.php
4 *
5 * @package Embera
6 * @author Michael Pratt <yo@michael-pratt.com>
7 * @link http://www.michael-pratt.com/
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13 namespace Embera\Provider;
14
15 use Embera\Url;
16
17 /**
18 * Smugmug Provider
19 * @link https://*.smugmug.com
20 * @link https://api.smugmug.com/services/oembed
21 */
22 class Smugmug extends ProviderAdapter implements ProviderInterface
23 {
24 /** inline {@inheritdoc} */
25 protected $endpoint = 'https://api.smugmug.com/services/oembed/?format=json';
26
27 /** inline {@inheritdoc} */
28 protected static $hosts = [
29 '*.smugmug.com'
30 ];
31
32 /** inline {@inheritdoc} */
33 protected $httpsSupport = true;
34
35 /** inline {@inheritdoc} */
36 public function validateUrl(Url $url)
37 {
38 return (bool) (preg_match('~smugmug\.com/([^/]+)/([^/]+)/([^/]+)$~i', (string) $url));
39 }
40
41 /** inline {@inheritdoc} */
42 public function normalizeUrl(Url $url)
43 {
44 $url->convertToHttps();
45 $url->removeQueryString();
46 $url->removeLastSlash();
47
48 return $url;
49 }
50
51 /** inline {@inheritdoc} */
52 public function modifyResponse(array $response = [])
53 {
54 if (empty($response['html']) && $response['type'] == 'photo') {
55 $html = [];
56 $html[] = '<div class="smugmug-html">';
57 $html[] = '<a href="' . $response['gallery_url'] . '" title="">';
58 $html[] = '<img src="' . $response['url'] . '" alt=""" title="">';
59 $html[] = '</a>';
60 $html[] = '</div>';
61
62 $response['html'] = implode('', $html);
63 }
64
65 return $response;
66 }
67
68 }
69