PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.37
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.37
3.37 3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 All 142 releases
photonic / Lightboxes / Features / Show_Videos_Inline.php

Show_Videos_Inline.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.37, at Lightboxes/Features/Show_Videos_Inline.php

45 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Photonic_Plugin\Lightboxes\Features;
4
5 use Photonic_Plugin\Components\Photo;
6 use Photonic_Plugin\Platforms\Base;
7
8 trait Show_Videos_Inline {
9 public function get_video_id(Photo $photo, Base $module): string {
10 return $module->provider . '-' . $module->gallery_index . '-' . $photo->id;
11 }
12
13 /**
14 * {@inheritDoc}
15 */
16 public function get_video_markup(Photo $photo, Base $module, string $indent): string {
17 $ret = '';
18 if (!empty($photo->video)) {
19 $video_id = $this->get_video_id($photo, $module);
20 $width = !empty($photo->main_size) ? ('width="' . $photo->main_size['w'] . '"') : '';
21 $height = !empty($photo->main_size) ? ('height="' . $photo->main_size['h'] . '"') : '';
22 $poster = !empty($photo->main_image) ? ('poster="' . $photo->main_image . '"') : '';
23 $ret .= $indent . "\t\t" . '<div class="photonic-html5-external" id="photonic-video-' . $video_id . '">' . "\n";
24 $ret .= $indent . "\t\t\t" . '<video class="photonic" controls preload="none" ' . $width . ' ' . $height . ' ' . $poster . '>' . "\n";
25 $ret .= $indent . "\t\t\t\t" . '<source src="' . $photo->video . '" type="' . ($photo->mime ?: 'video/mp4') . '">' . "\n";
26 $ret .= $indent . "\t\t\t\t" . esc_html__('Your browser does not support HTML5 videos.', 'photonic') . "\n";
27 $ret .= $indent . "\t\t\t" . '</video>' . "\n";
28 $ret .= $indent . "\t\t" . '</div>' . "\n";
29 }
30 return $ret;
31 }
32
33 /**
34 * {@inheritDoc}
35 */
36 public function get_grid_link(Photo $photo, array $short_code, Base $module): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
37 if (!empty($photo->video)) {
38 return esc_attr('#photonic-video-' . $this->get_video_id($photo, $module));
39 }
40 else {
41 return esc_url($photo->main_image);
42 }
43 }
44 }
45