| 1 |
<?php |
| 2 |
|
| 3 |
namespace Photonic_Plugin\Lightboxes; |
| 4 |
|
| 5 |
use Photonic_Plugin\Components\Photo; |
| 6 |
use Photonic_Plugin\Platforms\Base; |
| 7 |
|
| 8 |
require_once 'Lightbox.php'; |
| 9 |
|
| 10 |
class Lightgallery extends Lightbox { |
| 11 |
protected function __construct() { |
| 12 |
$this->library = 'lightgallery'; |
| 13 |
parent::__construct(); |
| 14 |
} |
| 15 |
|
| 16 |
public function get_photo_attributes(array $photo_data, Base $module): array { |
| 17 |
$out = parent::get_photo_attributes($photo_data, $module); |
| 18 |
if (!empty($photo_data['download'])) { |
| 19 |
$out['data-download-url'] = $photo_data['download']; |
| 20 |
} |
| 21 |
|
| 22 |
if (!empty($photo_data['video'])) { |
| 23 |
$out['data-video'] = esc_attr('{"source": [{"src": "' . $photo_data['video'] . '", "type": "video/mp4"}], "attributes": {"preload": false, "playsinline": true, "controls": true}}'); |
| 24 |
} |
| 25 |
|
| 26 |
$out['data-sub-html'] = $photo_data['title']; |
| 27 |
$out['data-photonic-thumb'] = $photo_data['thumbnail']; |
| 28 |
|
| 29 |
return $out; |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* {@inheritDoc} |
| 34 |
*/ |
| 35 |
public function get_grid_link(Photo $photo, array $short_code, Base $module): string { |
| 36 |
if (!empty($photo->video)) { |
| 37 |
return ''; |
| 38 |
} |
| 39 |
return parent::get_grid_link($photo, $short_code, $module); |
| 40 |
} |
| 41 |
} |
| 42 |
|