| @@ -1,24 +1,33 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace Photonic_Plugin\Lightboxes; |
| 3 | 4 | |
| 4 | -require_once('Lightbox.php'); | |
| 5 | +use Photonic_Plugin\Platforms\Base; | |
| 5 | 6 | |
| 7 | +require_once 'Lightbox.php'; | |
| 8 | + | |
| 6 | 9 | class Featherlight extends Lightbox { |
| 7 | 10 | protected function __construct() { |
| 8 | 11 | $this->library = 'featherlight'; |
| 9 | 12 | parent::__construct(); |
| 10 | - $this->class = ['photonic-launch-gallery', 'launch-gallery-featherlight']; | |
| 13 | + $this->class = ['photonic-lb', 'photonic-featherlight']; | |
| 11 | 14 | } |
| 12 | 15 | |
| 13 | - function get_photo_attributes($photo_data, $module) { | |
| 14 | - $mime = (!empty($photo['mime']) ? $photo['mime']: 'video/mp4'); | |
| 15 | - if ($module->provider == 'google' && empty($photo_data['video'])) { | |
| 16 | - return " data-featherlight-type='image' "; | |
| 16 | + public function get_photo_attributes(array $photo_data, Base $module): array { | |
| 17 | + $out = parent::get_photo_attributes($photo_data, $module); | |
| 18 | + $mime = (!empty($photo['mime']) ? $photo['mime'] : 'video/mp4'); | |
| 19 | + if ('google' === $module->provider && empty($photo_data['video'])) { | |
| 20 | + $out['data-featherlight-type'] = 'image'; | |
| 17 | 21 | } |
| 18 | - else if ($module->provider == 'google' && !empty($photo_data['video'])) { | |
| 19 | - return " data-featherlight='<video class=\"photonic\" controls preload=\"none\"><source src=\"".$photo_data['video']."\" type=\"".$mime."\">".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."</video>' data-featherlight-type='html'"; | |
| 22 | + elseif ('google' === $module->provider && !empty($photo_data['video'])) { | |
| 23 | + $out['data-featherlight'] = esc_attr("<video class=\"photonic\" controls preload=\"none\"><source src=\"" . $photo_data['video'] . "\" type=\"" . $mime . "\">" . esc_html__('Your browser does not support HTML5 videos.', 'photonic') . "</video>"); | |
| 24 | + $out['data-featherlight-type'] = 'html'; | |
| 20 | 25 | } |
| 26 | + elseif (!empty($photo_data['video'])) { | |
| 27 | + $out['data-featherlight'] = esc_attr("<video class=\"photonic\" controls preload=\"none\"><source src=\"" . $photo_data['video'] . "\" type=\"" . $mime . "\">" . esc_html__('Your browser does not support HTML5 videos.', 'photonic') . "</video>"); | |
| 28 | + $out['data-featherlight-type'] = 'video'; | |
| 29 | + } | |
| 21 | 30 | |
| 22 | - return !empty($photo_data['video']) ? " data-featherlight='<video class=\"photonic\" controls preload=\"none\"><source src=\"".$photo_data['video']."\" type=\"".$mime."\">".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."</video>' data-featherlight-type='video'" : ''; | |
| 31 | + return $out; | |
| 23 | 32 | } |
| 24 | -} | |
| 33 | +} | |